Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 11-15-2005, 10:28 PM   #1 (permalink)
Registered User
 
Join Date: Nov 2005
Posts: 1
OS: WIN XP


OHHHH GAWWWD HELP ME !!! I CANT FAIL THIS C++ COURSE !!!I've written some code! HELP!

I WILL POST THE CODE THAT I HAVE FOR YOU !!!!!! PLEASE JUST HELP!!!!!


HERE IT IS....OHH GAWWD HELP ME!!!

--------------------------------------------------------------------------



// It works but the loop is acting problematic.
Code:
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <fstream>

using namespace std ;



void MyStringgetline( string & temp);// Used from previous Homeworks

//Appointment Data Class def.

class Storage{

	string date;
	string time;//will need to change to CTime
	string appointment_Title, Location;
	string First_Name, Last_Name;
	string option;

public:

	void Getoption(void);
	void SetInfo(void);//Inputs all the information
	void Save(Storage pass, ofstream out);
};

main()
{
	Storage New_Data;
	
	char option;	
	char info;

	//used to write to files
	ofstream OutInfo;

	ifstream InInfo;	

	do
	{

		cout<< "Welcome"<<endl;
		cout<< "Please choose an option."<<endl;

		cout<< "'A' - Add New Appointment,'R'- Review Appointments"<<endl;
		cout<< "'S' Save Appointment, 'E' - To Exit" <<endl;
		
				
		
		option = cin.get() ;
	
		switch (option)
		{
		
		//Add New Appointment

		case 'a':
		case 'A': 
			
			//opens the needed file to where info is stored
			// need to close file at end
			//put out_passenger in out function
			
			New_Data.SetInfo();
			option = 0;
						
			break;
			
		//Review Appointments
		//Display on Screen
		case 'r':
		case 'R':
			
			InInfo.open( "AppointmentInfo.txt");
				if (InInfo.fail())
				{
					cerr<< "Sorry, but Weather.txt failed to load. "<< endl;
					exit(1);
				}


					
				InInfo.get(info);
					
				while (! InInfo.eof())
				{
					cerr<< info;
					InInfo.get(info);
				}
				cerr<<endl;
			
				option = 0;
			break;

		// Save appointments to file
		case 's':
		case 'S':
			
			OutInfo.open("AppointmentInfo.txt", ios::app );
			if (OutInfo.fail())
			{
				cout<<"Sorry, but could not open AppointmentInfo.txt"<<endl;
					exit(1);
			}
			else
				
			New_Data.Save(New_Data,OutInfo);
			
			option = 0;
			
			break;		
		//Exit Program
		case 'e':
		case 'E':

			cout<< "Goodbye, Have a Nice Trip."<<endl;

			break;

		default:
				cout<< "Sorry Invalid Entry, Please Try Again"<<endl;
		}
	
	}while('e' != option);			//|| 'E' != option)
	
	return 0;

}

void Storage::SetInfo(void)
{
	cout<< " Please Type in your First Name Followed By Your Last "<<endl;

		MyStringgetline(First_Name);
		MyStringgetline(Last_Name );

	cout<< "What Is The Appointment? "<<endl;
		MyStringgetline(appointment_Title);
	cout<< "What is the date?"<<endl;
		MyStringgetline(date);
	cout<< "Where Will This Be Located? "<<endl;
		MyStringgetline(Location);

}
void Storage::Getoption(void)
{
	MyStringgetline(option);
}

void MyStringgetline( string & temp)
{
	string x;

	getline(cin, x);
	temp = x;	
	return;	

}

void Storage::Save(Storage pass, ofstream out)
{

   out<<  "Name : "<< pass.First_Name << " " << pass.Last_Name <<endl;
   out<< "Location: "<< pass.Location << endl ;
   out<< "Date: " << pass.date<<endl;
   out<< "Appointment Type:"<< pass.appointment_Title <<endl;

}
--------------------------------------------------------------------------------

Help Me Get The Menu To Display To The Screen Once After The User Puts All The Inputs In There Not 5 Times!!!!!! And Help Me To Display The Info To The Screen When The User Is Done Putting The Inputs In!!!!
yaboyboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 11-16-2005, 02:01 AM   #2 (permalink)
Tech Hardware Team
 
Stu_computer's Avatar
 
Join Date: Jul 2005
Posts: 1,459
OS: Windows


while('e' != option); //|| 'E' != option)

should look like

while( ('e' != option) || ('E' != option) )


but if you do this...

option = cin.get() ;
option = toupper(option) // only need to test uppercase letters
switch (option)

then you only need look at uppercase letters and can finish with

while('E' != option);

.
__________________
Stu_computer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 11-23-2005, 06:20 AM   #3 (permalink)
Analyst, Security Team
 
MoralTerror's Avatar
 
Join Date: Nov 2005
Location: UK
Posts: 1,968
OS: xp


To display menu once the code should read


Code:
cout<< "Welcome"<<endl;
cout<< "Please choose an option."<<endl;

cout<< "'A' - Add New Appointment,'R'- Review Appointments"<<endl;
cout<< "'S' Save Appointment, 'E' - To Exit" <<endl;
		
				
		
option = cin.get() ;

         do
         {
                 switch (option)
                 {

Call a display procedure from

Code:
                case 'a':
		case 'A': 
			
			//opens the needed file to where info is stored
			// need to close file at end
			//put out_passenger in out function
			
			New_Data.SetInfo();
          //e.g         Display_NewData();
			option = 0;

Last edited by MoralTerror; 11-23-2005 at 06:50 AM.
MoralTerror is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 11-23-2005, 01:15 PM   #4 (permalink)
Register user
 
DeFcOn's Avatar
 
Join Date: Aug 2005
Location: Ewa Beach,Oahu
Posts: 240
OS: gentoo linux, sunwah linux, win xp pro, and SUSE 9.3


scratch that last statement i just read the whole thing...

Last edited by DeFcOn; 11-23-2005 at 01:18 PM. Reason: didn't read it thru
DeFcOn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 10:55 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85