I was asked to write a program that can choose a race and then an entry form with the participants name, boat name, if you want a tshirt and final cost. I have barely any experience and I have to finish it tonight. I have been working on it for days and it is killing me. Please help. Here is what I have so far:
#include <iostream>
using namespace std;
int
main ()
{
char part, boat, shirt;
char namePart; //Enter Participant's name
char nameBoat; //Enter Boat's name
char tshirt; //y or n to add a tshirt to your order
char race1, //Around the rocks, San Francisco
race2, //Tuesday night buoy races, Marina del Rey
race3, //Single-handed Transpac, San Francisco
endMenu; //Exit Menu
//Which race would the individual like to sign up for
cout << "Race Menu\n";
cout << endl;
cout << "1. Around the Rocks, San Francisco\n" << race1;
cout << "2. Tuesday Night Buoy Races, Marina del Rey\n" << race2;
cout << "3. Single-handed Transpac, San Francisco\n" << race3;
cout << "4. Exit Menu\n" << endMenu;
cout << endl;
int raceOption; //Selection of race option
double costTshirt = 12; //Cost of a tshirt
//Determine Race selected and deliver output information
if (raceOption == 1)
{
double cost1 = 300.00; //Cost of race 1
double sum1 = cost1 + costTshirt;
cout << "Welcome to Around the Rocks, San Francisco\n";
cout << "The cost of this race is $300.00\n";
cout << endl;
char namePart; //Enter Participant's name
char nameBoat; //Enter Boat's name
char tshirt; //y or n to add a tshirt to your order
double costTshirt = 12.00;
char part;
char boat;
char shirt;
cout << "Welcome to Tuesday Night Buoy Races, Marina del Rey\n";
cout << "The cost of this race is $250.00\n";
cout << endl;
char namePart; //Enter Participant's name
char nameBoat; //Enter Boat's name
char tshirt; //y or n to add a tshirt to your order
char part;
char boat;
char shirt;
double costTshirt = 12.00;
cout << "Please input your name: ";
cin >> namePart;
cout << "Welcome to Single-handed Transpac, San Francisco\n";
cout << "The cost of this race is $500.00\n";
cout << endl;
char namePart; //Enter Participant's name
char nameBoat; //Enter Boat's name
char tshirt; //y or n to add a tshirt to your order
char part;
char boat;
char shirt;
double costTshirt = 12.00;
cout << "Please input your name: ";
cin >> namePart;
Looking at the code, the main problem would seem to be using 'char' to store a name.
A char is for a single character, not a string.
Next, copy/paste is EVIL.
If you copy a block of text, and then make some changes to the copy, what you should be doing is making a function out of the copied code, and your edits then become the parameters of the function.
The only difference between the three cases are
- the name of the race
- the cost of the race.