Help i am struggling

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

cout << "Please choose option 1, 2, 3, or 4: ";
cin >> raceOption;
cout << endl;
cout << endl;



//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 << "Please input your name: ";
cin >> namePart;
cout << endl;

cout << "Please input boat name: ";
cin >> nameBoat;
cout << endl;

cout <<
"Do you wish to purchase this cool red and blue tshirt for $12? (y/n): ";
cin >> tshirt;
cout << endl;

cout << "Race selected: Around the Rocks, San Francisco\n";

cout << "Participant name: ";
part = namePart;
cout << part << endl;

cout << "Boat name: ";
boat = nameBoat;
cout << boat << endl;

cout << "Tshirt (y/n): ";
shirt = tshirt;
cout << shirt << endl;

cout << "Your balance: $";
cout << sum1 << endl;
}

if (raceOption == 2)
{

double cost2 = 250.00; //Cost of race 2

double sum2 = cost2 + costTshirt;

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 << "Please input boat name: ";
cin >> nameBoat;

cout <<
"Do you wish to purchase this cool red and blue tshirt for $12? (y/n): ";
cin >> tshirt;
cout << endl;

cout << "Race selected: Tuesday Night Buoy Races, Marina del Rey\n";

cout << "Participant name: ";
part = namePart;
cout << part << endl;

cout << "Boat name: ";
boat = nameBoat;
cout << boat << endl;

cout << "Tshirt (y/n): ";
shirt = tshirt;
cout << shirt << endl;

cout << "Your balance: $";
cout << sum2 << endl;

}
if (raceOption == 3)
{

double cost3 = 500.00; //Cost of race 3

double sum3 = cost3 + costTshirt;

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;

cout << "Please input boat name: ";
cin >> nameBoat;

cout <<
"Do you wish to purchase this cool red and blue tshirt for $12? (y/n): ";
cin >> tshirt;
cout << endl;

cout << "Race selected: Single-handed Transpac, San Francisco\n";

cout << "Participant name: ";
part = namePart;
cout << part << endl;

cout << "Boat name: ";
boat = nameBoat;
cout << boat << endl;

cout << "Tshirt (y/n): ";
shirt = tshirt;
cout << shirt << endl;

cout << "Your balance: $";
cout << sum3 << endl;
}
if (raceOption == 4)
{
cout << "Exit Menu\n";
return 0;
}




return 0;
}
There's no need to spam the board(s)
https://www.cplusplus.com/forum/beginner/276134/
sorry my comp froze and i didnt show it posted i deleted it
Last edited on
On any forum, there are usually guidelines for posting code.
https://www.cplusplus.com/articles/jEywvCM9/

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.

All together
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
#include <string>
using namespace std;

void enterRace(string nameOfRace, double entryCost ) {
  cout << "Welcome to " << nameOfRace << endl;
  cout << "The cost of this race is $" << entryCost << endl;

  cout << "Please input your name: ";
  string namePart;  // You used char, which can only hold a single char
  cin >> namePart;
  cout << endl;

  cout << "Please input boat name: ";
  string nameBoat;
  cin >> nameBoat;
  cout << endl;

  cout << "Do you wish to purchase this cool red and blue tshirt for $12? (y/n): ";
  char tshirt;
  cin >> tshirt;
  cout << endl;

  cout << "Race selected   : " << nameOfRace << endl;
  cout << "Participant name: " << namePart << endl;
  cout << "Boat name       : " << nameBoat << endl;
  cout << "Tshirt (y/n)    : " << tshirt << endl;

  double cost = entryCost;
  if ( tshirt == 'y' )
    cost += 12;
  cout << "Your balance    : $" << cost << endl;
}

int main()
{
  // These should be arrays
  string race1 = "Around the Rocks, San Francisco";
  string race2 = "Tuesday Night Buoy Races, Marina del Rey";
  string race3 = "Single-handed Transpac, San Francisco";
  double cost1 = 300.00;
  double cost2 = 250.00;
  double cost3 = 500.00;

  //Which race would the individual like to sign up for
  cout << "Race Menu\n";
  cout << "1. " << race1 << "\n" ;
  cout << "2. " << race2 << "\n" ;
  cout << "3. " << race3 << "\n" ;
  cout << "4. Exit Menu\n";
  cout << "Please choose option 1, 2, 3, or 4: ";
  int raceOption;
  cin >> raceOption;
  cout << endl;
  cout << endl;

  //Determine Race selected and deliver output information
  if (raceOption == 1) {
    enterRace(race1,cost1);
  }
  if (raceOption == 2) {
    enterRace(race2,cost2);
  }
  if (raceOption == 3) {
    enterRace(race3,cost3);
  }
  if (raceOption == 4) {
    cout << "Exit Menu\n";
    return 0;
  }

  return 0;
}


$ g++ -Wall foo.cpp
$ ./a.out 
Race Menu
1. Around the Rocks, San Francisco
2. Tuesday Night Buoy Races, Marina del Rey
3. Single-handed Transpac, San Francisco
4. Exit Menu
Please choose option 1, 2, 3, or 4: 2


Welcome to Tuesday Night Buoy Races, Marina del Rey
The cost of this race is $250
Please input your name: fred

Please input boat name: bedrock

Do you wish to purchase this cool red and blue tshirt for $12? (y/n): y

Race selected   : Tuesday Night Buoy Races, Marina del Rey
Participant name: fred
Boat name       : bedrock
Tshirt (y/n)    : y
Your balance    : $262

Topic archived. No new replies allowed.