473,396 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to make a loop that asks user if they want to enter more information?

I want the user to enter information, such as names, and then I want to ask them after they entered the first name if they want to enter another name. How would I do that?

This is what I have so far:

cout << "Would you like to enter an artist's information? ";
cin >> answer;

if(answer = 'Y' || 'y')
{
cout << "Enter artist: ";
cin.getline(line, 50);// >> line;
myfile << line << endl;
cout << "Enter album: ";
cin.getline(line, 50);// >> line;
myfile << line << endl;
cout << "Enter track: ";
cin.getline(line, 50);// >> line;
myfile << line << endl;
cout << "Enter song: ";
cin.getline(line, 50);// >> line;
.
.
.
}

Here's what happens:

Would you like to enter an artist's information? y
Enter artist: Enter album: 2pac
Enter track: 2
Enter song: f
Enter genre: a

It skips where you enter the artist name. Also, it doesn't matter whether you put y or a;osidhfasd in after it asks to enter more info. It goes on no matter what.
May 4 '07 #1
2 1669
ilikepython
844 Expert 512MB
See my reply in your original thread.
May 4 '07 #2
Instead the if condition, you need to use a DO WHILE, and before you end the cicle, ask the question again, and then in the condition WHILE you need to put While(answer=='y'||'Y'). That should work.
May 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: tina.boroff | last post by:
I have a combo box that gathers insurance company names from my CCtable. If you add a name that isn't in the list it: 1)asks if you want to add the company 2)if so opens up the CCform (based on...
13
by: Redduck | last post by:
Hello everyone. I am frustrated, I have written the simple program below for a class and I am having problems with the DO-WHILE loop. On the first run through the loop, everything works well, the...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
17
by: stubbsie | last post by:
Hi, I have redesigned our official public government website in .net and it has taken me a few months to redo. I have been the sole designer of the website from its humble beginnning a few years...
2
by: Sudz28 | last post by:
Hi! I'm trying to write a program that solicits the user for input and then asks them if they wish to run it again (y/n). I can't quite figure out how to work the loop though with the y/n response....
5
by: justbovo | last post by:
Hello, My name is Justin. I am working on a part of a Find Memory module for a program. Here's how it works.. I enter '13' at the main menu which branches out to my Find Memory module. I ask...
1
by: zelmila19 | last post by:
Hi can anyone tell me how to do this problem: Write a program using a while loop that asks the user to enter their sales for each month until they enter -1 (sentinel value). After this, it should...
2
by: cmb3587 | last post by:
I am having a problem with the validation of the account number and password. The beginning of the program asks for users account # then pwd. The program is then supposed to go to a checkID...
1
by: rockchicx23 | last post by:
i have to write a program that is a guessing the number game. the user has to choose the number of games they want to play. i need help setting up the loop that will run the number of times the user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.