Monday, May 24, 2010

How do u program this c++ visual program using the following libraries?

Topic: Write a program that allows the user to enter numbers in the range 0-19, terminated by a sentinel, and then perform the following functiosn on the numbers: the average number, the maximum number, the range, the median





#include%26lt;iostream%26gt;


#include%26lt;vector%26gt;


#include%26lt;string%26gt;


#include%26lt;stdlib.h%26gt;


#include%26lt;time.h%26gt;





using namespace std;

How do u program this c++ visual program using the following libraries?
Try this:





cout %26lt;%26lt; "1"


cout %26lt;%26lt; "am 2"


cout %26lt;%26lt; "st"


cout %26lt;%26lt; "up"


cout %26lt;%26lt; "id"


cout %26lt;%26lt; "an"


cout %26lt;%26lt; "d la"


cout %26lt;%26lt; "zy 2"


cout %26lt;%26lt; "due"


cout %26lt;%26lt; "hom"


cout %26lt;%26lt; "e"


cout %26lt;%26lt; "work"
Reply:Why do you have to use those libs?





Looks like all you'd need is iostream.





int myInput=0;


do {


cout %26lt;%26lt; "Give me a number: ";


cin %26gt;%26gt; myInput;


if (myInput == -1) {


cout %26lt;%26lt; "C-ya!" %26lt;%26lt; endl;


}


else if (myInput %26lt; 0 || myInput %26gt;19) {


cout %26lt;%26lt; "Bad number... Try again!" %26lt;%26lt; endl;


}


else


numbersRead++;


numberTotal+=myInput;


if (myInput%26gt;maxNumber)


maxNumber=myInput;





and so on...





Your instructor would probably want you to complete it yourself.


No comments:

Post a Comment