Computer Information System Program

In summary: Computer( Computer2 ); /* print Computer3 info... */ printComputer( Computer3 ); /* print Computer4 info... */ printComputer( Computer4 ); /* print Computer5 info... */ printComputer( Computer5 ); return 0;}In summary, the programmer created a Computer Information System that will keep up to 50 Computer data. The system will include a computer structure and an array of Computer objects. The program will be able to search for a particular computer by ComputerID and ComputerName, and will also be able to display a list of all computers.
  • #1
Henry R
25
0
Good day everyone.

I have some problems here. I need help.:confused: This code is my attempt to build a computer program.But, I just found out that I am confuse with my own code.You guys, can check it by your own and please try to fix it.;) Give mesuggestions. If thers's anything wrong then write it to me. There's an image attachment. And, I think I make a lots of mistakes there. I just don't know how to put the right code on right position. Please, tell me the right line of this code. The function,method and arguments. Just tell me . Thank you, so much. And, I also has paste my code here.

Before that, here's the question :

To solve a programming problem by creating a structure which stores information of Computers and to manipulate the structure by using arrays and functions.

A software company has requested you to implement a Computer Information System that will keep up to a maximum of 50 Computer data. The computer’s information to be kept is:
• ComputerID – int
• ComputerName – 50 characters
• ProcessorSpeed – integer
• RAM - Integer
• OperatingSystem – 50 characters
• Price - float

You would need to create a Computer structure and an array called Computers. You are requested to test the Computer Information System developed by performing the tasks b) to e), and display its output.

a)Declare the Computer structure and the Computers array, using the information given above.

b)Insert 5 new computers using a sequential ComputerID

c)Search for a particular computer by ComputerID

d)Search for a particular computer by ComputerName

e)Display a list of all computers Last but not least , this is my program. Not that good right?
View attachment 3537This is my code ...

int SequentialSearch(int list[], int );

/*Computer Information System Programme*/
#include <stdio.h>
#include <string.h>
#include<windows.h>
#include <stdlib.h>
#define N 50
#define TARGET 5

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

/* Name of constructed struct that must fulfill the naming rule of a variable.*/
struct Computers
{
/* DEclaration of local variables */
int i,j;
char ComputerSpecifications [50];
int ComputerID;
char ComputerName [50];
int ProcessorSpeed;
int RAM;
char OperatingSystem [50];
float Price;
};

/* function declaration */
void printComputer( struct Computers computer );
int main(int argc, char *argv[])
{
/*To display or print some brief details of programmer of this program*/
printf("////////////////////////////////////////////////////////////////////////////////\n");
printf("\tProgrammer : Your Name.\n");
printf("\tQuestion No : Question 1.\n\n");

printf("\tTHIS PROGRAM STORES FIVE NEW COMPUTER INFORMATION SYSTEM.\n");
printf("\tIT WILL KEEP UP TO A MAXIMUM 50 COMPUTER DATA.\n");
printf("////////////////////////////////////////////////////////////////////////////////\n");
printf("\tBelow are the specifications of five new computers.\n\n");

struct Computers Computer1; /* Declare Computer1 of type Computer */
struct Computers Computer2; /* Declare Computer2 of type Computer */
struct Computers Computer3; /* Declare Computer3 of type Computer */
struct Computers Computer4; /* Declare Computer4 of type Computer */
struct Computers Computer5; /* Declare Computer5 of type Computer */

/* computer 1 specification */
strcpy( Computer1.ComputerSpecifications, "COMPUTER ONE SPECIFICATIONS");
Computer1.ComputerID = 10111;
strcpy( Computer1.ComputerName, "Asus");
Computer1.ProcessorSpeed = 5;
Computer1.RAM = 8 ;
strcpy( Computer1.OperatingSystem, "Microsoft Windows 8");
Computer1.Price = 2459.00;


/* computer 2 specification */
strcpy( Computer2.ComputerSpecifications, "COMPUTER TWO SPECIFICATIONS");
Computer2.ComputerID = 20222;
strcpy( Computer2.ComputerName, "Apple Macintosh");
Computer2.ProcessorSpeed = 9;
Computer2.RAM = 16 ;
strcpy( Computer2.OperatingSystem, "Apple");
Computer2.Price = 2459.00;

/* computer 3 specification */
strcpy( Computer3.ComputerSpecifications, "COMPUTER THREE SPECIFICATIONS");
Computer3.ComputerID = 30333;
strcpy( Computer3.ComputerName, "Lenovo");
Computer3.ProcessorSpeed = 9;
Computer3.RAM = 4 ;
strcpy( Computer3.OperatingSystem, "Microsoft Windows 7");
Computer3.Price = 1459.00;

/* computer 4 specification */
strcpy( Computer4.ComputerSpecifications, "COMPUTER FOUR SPECIFICATIONS");
Computer4.ComputerID = 40444;
strcpy( Computer4.ComputerName, "Dell");
Computer4.ProcessorSpeed = 9;
Computer4.RAM = 8 ;
strcpy( Computer4.OperatingSystem, "Linux Ubuntu");
Computer4.Price = 1600.00;

/* computer 5 specification */
strcpy( Computer5.ComputerSpecifications, "COMPUTER FIVE SPECIFICATIONS");
Computer5.ComputerID = 50555;
strcpy( Computer5.ComputerName, "Alienware");
Computer5.ProcessorSpeed = 20;
Computer5.RAM = 24 ;
strcpy( Computer5.OperatingSystem, "Android");
Computer5.Price = 5500.00;


/* print Computer1 info */
printComputer( Computer1 );

/* print Computer2 info */
printComputer( Computer2 );

/* print computer3 info */
printComputer( Computer3 );

/* print computer4 info */
printComputer( Computer4 );

/*print computer5 info */
printComputer( Computer5 );
return 0;
}/* Function declarations */
void printComputer( struct Computers computer )
{

printf( "\n\t%s\n", computer.ComputerSpecifications);
printf( "\n\tComputer ID\t :%d\n", computer.ComputerID);
printf( "\tComputer Name :%s\n", computer.ComputerName);
printf( "\tProcessor Speed :CPU %dGhz\n", computer.ProcessorSpeed);
printf( "\tInstalled Memory (RAM) :%d.00 GB\n", computer.RAM);
printf( "\tOperating System Type :%s\n", computer.OperatingSystem);
printf( "\tPrice (RM) :%.2f\n\n\n",computer.Price);


/* Declaration of local variables */
int i, data [12];
int ComputerID, found;

/*Enter data into an array of size 50*/
for (i = 0; i < TARGET ; i++)
{
printf("Enter computer data %d:", (i+1));
scanf ("\n%d", &data);
}

/* Search operation */
printf("What computer do you want to search? : ");
scanf("%d", &ComputerID);
found = SequentialSearch (data,ComputerID);
if (found != -1 )
printf("Found computer at the %d\n ", ComputerID, found);
else
printf("Data not found");
}

/*Function to search list */
int SequentialSearch (int list[], int SearchData)
{
int location = -1;
int indx;
for (indx = 0; indx <= TARGET; indx++){
if (SearchData == list[indx])
location = indx;
}
return location;
system("PAUSE");
return 0;
}
 

Attachments

  • Question 1.PNG
    Question 1.PNG
    13.1 KB · Views: 104
Last edited:
Technology news on Phys.org
  • #2
Henry R said:
Good day everyone.

I have some problems here. I need help.:confused: This code is my attempt to build a computer program.But, I just found out that I am confuse with my own code.You guys, can check it by your own and please try to fix it.;) Give mesuggestions. If thers's anything wrong then write it to me. There's an image attachment. And, I think I make a lots of mistakes there. I just don't know how to put the right code on right position. Please, tell me the right line of this code. The function,method and arguments. Just tell me . Thank you, so much. And, I also has paste my code here.

Before that, here's the question :

To solve a programming problem by creating a structure which stores information of Computers and to manipulate the structure by using arrays and functions.

A software company has requested you to implement a Computer Information System that will keep up to a maximum of 50 Computer data. The computer’s information to be kept is:
• ComputerID – int
• ComputerName – 50 characters
• ProcessorSpeed – integer
• RAM - Integer
• OperatingSystem – 50 characters
• Price - float

You would need to create a Computer structure and an array called Computers. You are requested to test the Computer Information System developed by performing the tasks b) to e), and display its output.

a)Declare the Computer structure and the Computers array, using the information given above.

b)Insert 5 new computers using a sequential ComputerID

c)Search for a particular computer by ComputerID

d)Search for a particular computer by ComputerName

e)Display a list of all computers Last but not least , this is my program. Not that good right?
View attachment 3537This is my code ...

int SequentialSearch(int list[], int );

/*Computer Information System Programme*/
#include <stdio.h>
#include <string.h>
#include<windows.h>
#include <stdlib.h>
#define N 50
#define TARGET 5

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

/* Name of constructed struct that must fulfill the naming rule of a variable.*/
struct Computers
{
/* DEclaration of local variables */
int i,j;
char ComputerSpecifications [50];
int ComputerID;
char ComputerName [50];
int ProcessorSpeed;
int RAM;
char OperatingSystem [50];
float Price;
};

/* function declaration */
void printComputer( struct Computers computer );
int main(int argc, char *argv[])
{
/*To display or print some brief details of programmer of this program*/
printf("////////////////////////////////////////////////////////////////////////////////\n");
printf("\tProgrammer : Your Name.\n");
printf("\tQuestion No : Question 1.\n\n");

printf("\tTHIS PROGRAM STORES FIVE NEW COMPUTER INFORMATION SYSTEM.\n");
printf("\tIT WILL KEEP UP TO A MAXIMUM 50 COMPUTER DATA.\n");
printf("////////////////////////////////////////////////////////////////////////////////\n");
printf("\tBelow are the specifications of five new computers.\n\n");

struct Computers Computer1; /* Declare Computer1 of type Computer */
struct Computers Computer2; /* Declare Computer2 of type Computer */
struct Computers Computer3; /* Declare Computer3 of type Computer */
struct Computers Computer4; /* Declare Computer4 of type Computer */
struct Computers Computer5; /* Declare Computer5 of type Computer */

/* computer 1 specification */
strcpy( Computer1.ComputerSpecifications, "COMPUTER ONE SPECIFICATIONS");
Computer1.ComputerID = 10111;
strcpy( Computer1.ComputerName, "Asus");
Computer1.ProcessorSpeed = 5;
Computer1.RAM = 8 ;
strcpy( Computer1.OperatingSystem, "Microsoft Windows 8");
Computer1.Price = 2459.00;


/* computer 2 specification */
strcpy( Computer2.ComputerSpecifications, "COMPUTER TWO SPECIFICATIONS");
Computer2.ComputerID = 20222;
strcpy( Computer2.ComputerName, "Apple Macintosh");
Computer2.ProcessorSpeed = 9;
Computer2.RAM = 16 ;
strcpy( Computer2.OperatingSystem, "Apple");
Computer2.Price = 2459.00;

/* computer 3 specification */
strcpy( Computer3.ComputerSpecifications, "COMPUTER THREE SPECIFICATIONS");
Computer3.ComputerID = 30333;
strcpy( Computer3.ComputerName, "Lenovo");
Computer3.ProcessorSpeed = 9;
Computer3.RAM = 4 ;
strcpy( Computer3.OperatingSystem, "Microsoft Windows 7");
Computer3.Price = 1459.00;

/* computer 4 specification */
strcpy( Computer4.ComputerSpecifications, "COMPUTER FOUR SPECIFICATIONS");
Computer4.ComputerID = 40444;
strcpy( Computer4.ComputerName, "Dell");
Computer4.ProcessorSpeed = 9;
Computer4.RAM = 8 ;
strcpy( Computer4.OperatingSystem, "Linux Ubuntu");
Computer4.Price = 1600.00;

/* computer 5 specification */
strcpy( Computer5.ComputerSpecifications, "COMPUTER FIVE SPECIFICATIONS");
Computer5.ComputerID = 50555;
strcpy( Computer5.ComputerName, "Alienware");
Computer5.ProcessorSpeed = 20;
Computer5.RAM = 24 ;
strcpy( Computer5.OperatingSystem, "Android");
Computer5.Price = 5500.00;


/* print Computer1 info */
printComputer( Computer1 );

/* print Computer2 info */
printComputer( Computer2 );

/* print computer3 info */
printComputer( Computer3 );

/* print computer4 info */
printComputer( Computer4 );

/*print computer5 info */
printComputer( Computer5 );
return 0;
}/* Function declarations */
void printComputer( struct Computers computer )
{

printf( "\n\t%s\n", computer.ComputerSpecifications);
printf( "\n\tComputer ID\t :%d\n", computer.ComputerID);
printf( "\tComputer Name :%s\n", computer.ComputerName);
printf( "\tProcessor Speed :CPU %dGhz\n", computer.ProcessorSpeed);
printf( "\tInstalled Memory (RAM) :%d.00 GB\n", computer.RAM);
printf( "\tOperating System Type :%s\n", computer.OperatingSystem);
printf( "\tPrice (RM) :%.2f\n\n\n",computer.Price);


/* Declaration of local variables */
int i, data [12];
int ComputerID, found;

/*Enter data into an array of size 50*/
for (i = 0; i < TARGET ; i++)
{
printf("Enter computer data %d:", (i+1));
scanf ("\n%d", &data);
}

/* Search operation */
printf("What computer do you want to search? : ");
scanf("%d", &ComputerID);
found = SequentialSearch (data,ComputerID);
if (found != -1 )
printf("Found computer at the %d\n ", ComputerID, found);
else
printf("Data not found");
}

/*Function to search list */
int SequentialSearch (int list[], int SearchData)
{
int location = -1;
int indx;
for (indx = 0; indx <= TARGET; indx++){
if (SearchData == list[indx])
location = indx;
}
return location;
system("PAUSE");
return 0;
}


Hi Henry R!

Your problem statement says: "You would need to create a Computer structure and an array called Computers."

Currently you have a structure named [m]Computers[/m] that actually contains the information about 1 computer.
So I suggest you change the name to [m]Computer[/m], which would satisfy the first part of the sentence.

You still have to create an array called "Computers".
How would an array be declared? (Wondering)

Furthermore, you have a function:
Code:
int SequentialSearch (int list[], int SearchData)
This function is supposed to search in an array for specific data.
However, for this problem your array (named "list") does not contain integers, but [m]Computer[/m]'s, so perhaps you can change the type [m]int[/m] to [m]Computer[/m] and adjust the function to search for a "ComputerId" in that array? (Wondering)
 
  • #3
I like Serena said:
Hi Henry R!

Your problem statement says: "You would need to create a Computer structure and an array called Computers."

Currently you have a structure named [m]Computers[/m] that actually contains the information about 1 computer.
So I suggest you change the name to [m]Computer[/m], which would satisfy the first part of the sentence.

You still have to create an array called "Computers".
How would an array be declared? (Wondering)

Furthermore, you have a function:
Code:
int SequentialSearch (int list[], int SearchData)
This function is supposed to search in an array for specific data.
However, for this problem your array (named "list") does not contain integers, but [m]Computer[/m]'s, so perhaps you can change the type [m]int[/m] to [m]Computer[/m] and adjust the function to search for a "ComputerId" in that array? (Wondering)
Thank you... I just try my best.
 
  • #4
I like Serena said:
Hi Henry R!

Your problem statement says: "You would need to create a Computer structure and an array called Computers."

Currently you have a structure named [m]Computers[/m] that actually contains the information about 1 computer.
So I suggest you change the name to [m]Computer[/m], which would satisfy the first part of the sentence.

You still have to create an array called "Computers".
How would an array be declared? (Wondering)

Furthermore, you have a function:
Code:
int SequentialSearch (int list[], int SearchData)
This function is supposed to search in an array for specific data.
However, for this problem your array (named "list") does not contain integers, but [m]Computer[/m]'s, so perhaps you can change the type [m]int[/m] to [m]Computer[/m] and adjust the function to search for a "ComputerId" in that array? (Wondering)
Can you give website links that I can refer to? Just that. Thanks for helping. I've been searching for good examples. But, I got none of them.
 
  • #5
Henry R said:
Can you give website links that I can refer to? Just that. Thanks for helping. I've been searching for good examples. But, I got none of them.

What kind of website link are you looking for?
 
  • #6
I like Serena said:
What kind of website link are you looking for?

Website of C programming language that stores computer data records. Please,please, please...:eek: There's a lot of website but, you know I couldn't find them.
 

FAQ: Computer Information System Program

What is a Computer Information System Program?

A Computer Information System Program is a specialized degree program that focuses on the study of computers and their use in managing and organizing information. It involves learning about programming, networking, database management, and other related topics.

What are the career opportunities for graduates of a Computer Information System Program?

Graduates of a Computer Information System Program have a wide range of career opportunities in industries such as technology, healthcare, finance, and government. They can work as computer programmers, network administrators, database administrators, IT consultants, and more.

What skills are required to succeed in a Computer Information System Program?

To succeed in a Computer Information System Program, students should have strong analytical and problem-solving skills, as well as a good understanding of math and logic. They should also be able to work well with others, have good communication skills, and be interested in technology and computers.

What are the benefits of studying a Computer Information System Program?

Studying a Computer Information System Program can provide many benefits, including a strong foundation in technology and computer skills, a versatile degree that can lead to various career opportunities, and a high demand for professionals in this field. It can also be a rewarding and challenging career path for those interested in solving complex problems and working with cutting-edge technology.

Is a Computer Information System Program a good choice for someone without a strong background in technology?

Yes, a Computer Information System Program can be a good choice for someone without a strong background in technology. Many programs offer introductory courses to help students develop the necessary skills and knowledge for success. Additionally, the program covers a broad range of topics, so there is something for everyone, regardless of their previous experience with technology.

Similar threads

Replies
3
Views
2K
Back
Top