Thursday, July 9, 2009

C++??? 10 points to whoever solve this problem.?

Here is the question:





1. Write the declaration section for a program that will allow user entry of a part number (assume that the number is in the range of 1 through 30000), a part description (maximum number of characters: 25), and a unit price.








2. Write the input section to allow the user to enter the values for the declarations above.








3. Write the output section that will send the values mentioned above to the output stream with appropriate labels and an appropriate title.


Sample Output:





Zeke’s Parts


=============


Part Number: 22345


Part Description: Big Wrench


Price of Part: 18.65








And here is the template used:





int main(void)


{


int choice;


char drive[2],


disk_file[15],


file[9];


ofstream outfile;


// input section


// replace this comment with input statements


// process section


//replace this comment with process statements


// output section


system ("cls");


cout %26lt;%26lt; "Output to console (1) or disk file (2): ";


cin %26gt;%26gt; choice;


if ( choice == 1 )


{ system ("cls");


outfile.open("con");


}


else //routine allows interactive entry of external file name


{ cout %26lt;%26lt; "Which drive: a, b, c, d, e, or f ? ";


cin %26gt;%26gt; drive;


strcpy(disk_file, drive);


strcat(disk_file, ":");


cout %26lt;%26lt; "Enter a results file name: ";


cin %26gt;%26gt; file;


strcat(disk_file, file);


strcat(disk_file, ".dta");


outfile.open(disk_file);


}


outfile %26lt;%26lt; setiosflags(ios::showpoint | ios::fixed) %26lt;%26lt; setprecision(2);


// replace this comment with output statements


outfile.close();


cout %26lt;%26lt; endl %26lt;%26lt; endl; // provides blank line before pause display message


system ("pause");


return 0;


}

C++??? 10 points to whoever solve this problem.?
I won't bother writing the whole code (that's your work) but I'll give you some helpful advice. For example, they give you a set of information that each party HAS to have. The part number, the description, and the unit price. To make it easier, use structs. Like this





struct hardware


{


unsigned int PartNumer;


char description[25];


double price;


}





Then you just create the hardware type (which can be in the form of a .txt file or whatever output you wnat)





hardware Wrench;





That means you can just keep making a variable of type hardware and each one will store an unsigned int for a part number, a description of type char, and a price which can have decimals.





Then you can just use cout/cin statements and write to the struct. For example





cout %26lt;%26lt; "Please enter part number: " %26lt;%26lt; endl;


cin %26gt;%26gt; partnumber;





Then all you have to do is set a loop to look for a matching part number or whatever the search parameter was to match the hardware struct data type.
Reply:http://www.doyourownhomework.com





and forget the points
Reply:If you are still stuck with your project assignment , may be you can contact a C++ expert live at website like http://askexpert.info/
Reply:These people above would give you an answer had it been an easy question. I would, too.
Reply:haha...i agree! Do your own homework! The best way to learn C++ or any programming language is to just play around with it and figure it out for yourself! You can ask for suggestions, but never ask somebody to do something FOR you!!! Besides, if you never do it yourself, you'll never get that feeling of accomplishment that comes when you run your own program and it finally works!!! lol


No comments:

Post a Comment