PDA

View Full Version : c++ help


pat8612
03-24-2005, 09:24 PM
hi im new to programming. im starting with c++ i think this is a good starting language. i see alot on java and i want to learn that next. why is java better?

im working on a c++ problem - I'm in the control structure chapter. i need to ask for 5 numbers from 1-30 and then based on the number print that many *** so if 4 is entered i need to print ****. i understand while and for structures but havent done any switch problems yet. i started to declare variable num1 -num30 and count. to count from 1 to 5 loop 5 times. im thinking about setting up a switch but not sure how to. theres one example in the book that uses
while (( grade = cin.get() ) !=EOF {

but i dont want to ask the user to end i want to count up to five - loop five times. could i use for ( count =1; count <= 5, count++ )
im not sure what the cin.get() is?

would i need to have 30 cases?
any help is appreciated.

Dr. Evil
03-24-2005, 09:47 PM
Just loop five times, as you asked, and ask the user for 5 integers. Check to make sure they're in range, and if they are, make another for() loop to loop until the number they entered, and print a '*' on every iteration.

pat8612
03-24-2005, 09:57 PM
so use a switch. - do i need to use cin.get()? and do i need 30 cases?

Jason
03-24-2005, 11:04 PM
no, forget switch and you only need cin


Jason