#include <iostream>
#include <string>

using namespace std;

int main()
{
	// A switch program that shows the user his input choice 

	string word1 = "Achieve";

	cout << "Welcome to Your AccuWeather Report Screen." << endl;
	cout << "Your choices are listed at the bottom." << endl;

	cout << "Number 1 - Temperature outside right now" << endl;
	cout << "Number 2 - Stock Price of the day" << endl;
	cout << "Number 3 - Word of the day" << endl;
	cout << "Number 4 - Check the Last account that was opened" << endl;

	int Answer;
	cout << "Answer : ";
	cin >> Answer;

	// Shows the outcome of the operators number input

	switch (Answer)
	{
	case 1:
		cout << " It's a sunny, 85F, warm day with a nice chilling breeze comming from the north";
		break;

	case 2:
		cout << "Stock Price as of 2 pm is $3.45 per share";
		break;

	case 3: 
		cout << word1;
		break;

	case 4:
		cout << "Mr. Jones...he was selling his cat on Craigslist for 5 Pesos. No one bought his cat. =( ";
		break;

	// Incase if user inputs a wrong choice 

	default:
		cout << "What did you type?? Try again!";

	// Code used to generate try again

		char again = 'y';
		while (again == 'y')
		{
			cout << "Try again?? (y/n): ";
			cin >> again;
		}

		cout << " Bye!!!" << endl;


	system("PAUSE");
	return 0;
}

this show the error:

Error 1 error C1075: end of file found before the left brace '{' at 'c:\users\hp\documents\visual studio 2010\projects\week3assign\week3assign\week3.cpp(7)' was matched c:\users\hp\documents\visual studio 2010\projects\week3assign\week3assign\week3.cpp

Count your braces, you never closed the switch block off.

Can you show me the correct way?

Put a } after the default case.

You also need to rearrange your loop so that it encompasses from cin >> Answer all the way down to the end of your switch block. Just prompting the user like you did won't loop back to the beginning.

// This is a program that displays the choice the user picks using a Switch Statement

#include <iostream>
#include <string>

using namespace std;

int main()
{
	// Underneath A switch program that shows the user his input choice 

	string word1 = "Achieve";

	cout << "Welcome to Your AccuWeather Report Screen." << endl;
	cout << endl;
	cout << "Your choices are listed at the bottom." << endl;
	cout << endl;
	cout << "Choose what you want to view" << endl;
	cout << endl;
	cout << "Number 1 - Temperature outside right now" << endl;
	cout << endl;
	cout << "Number 2 - Stock Price of the day" << endl;
	cout << endl;
	cout << "Number 3 - Word of the day" << endl;
	cout << endl;
	cout << "Number 4 - Check the Last account that was opened" << endl;
	cout << endl;

	int Answer;
	cout << "Answer : ";
	cin >> Answer;
	cout << endl;

	// Underneath Shows the outcome of the operators number input

	switch (Answer)
	{
	case 1:
		cout << "It's a nice, sunny, 85 degree warm day today. We have a nice chilling breeze coming in from the north today, so I advise people to go outside and enjoy the day" << endl;
		cout << endl;
		break;

	case 2:
		cout << "Stock Price as of 2 pm today is $3.45 per share." << endl;
		cout << endl;
		break;

	case 3: 
		cout << "Our 'Word of the Day' is :  " << word1 << endl;
		cout << endl;
		break;

	case 4:
		cout << "Last Account Opened: Mr. Jones.  " << endl;
		cout << endl;
		cout << "Reason: Selling his cat on Craigslist." << endl;
		cout << endl;
		break;

	// if user inputs a wrong choice, I prompted them 

	default:
		cout << " What did you type??" << endl;

	// Code used to generate the try again

	char again = 'y', no = 'n';
	while ((again == 'y') && (no == 'n'))
	{
		cout << "Try again? (y/n) ";
		cin >> again;
		cout << endl;
		cout << endl;
		cout << endl;

	  // Gives you your options again

		cout << "Here are your choices again " << endl;
		cout << endl;
		cout << main();
		if (cin >> no)
		{
			cout << "Good Bye" << endl;
		}
	}
	}

	system("PAUSE");
	return 0;
}

I need help making my program say "Good Bye" if the user inputs n for try again. Otherwise my program runs

Try thinking about the answer. Where do YOU think the output makes sense?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.