![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| 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: * 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 |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#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!!!! |
|
|
|
| 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 |
|
|
#2 (permalink) |
|
Tech Hardware Team
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); .
__________________
|
|
|
|
|
|
#3 (permalink) |
|
Analyst, Security Team
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. |
|
|
|
![]() |
| Thread Tools | |
|
|