#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

Edited 5 Years Ago by WaltP: Added CODE Tags -- learn to use them!

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.

Edited 5 Years Ago by jonsca: n/a

// 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

Edited 5 Years Ago by WaltP: Added CODE Tags again -- use them

This article has been dead for over six months. Start a new discussion instead.