I wrote this code last week and it is not entirely correct. I have to add Create functions based on your existing source code (ex. GetCar, CreateCar, CalculateLapTime) which take in the appropriate parameters and give the correct output. Use pointers where applicable.
Move validation code into functions where appropriate, and throw an exception if the input does not match your validation rules. Handle the exceptions accordingly in your main function, and output the error message to the console.
To it for this week. I need help badly. I am lost. Code below from last week......
#include <iostream>
#include <string>
usingnamespace std;
struct Car
{
std::string color;
std::string driver_name;
int number;
int t_minutes;
int t_seconds;
};
int main()
{
constint SIZE = 3;
Car cars[SIZE];
// fill up the array with Cars
for (int i = 0; i < SIZE; i++)
{
std::cout << "Who is the driver for car " << i + 1 << "? ";
std::getline(std::cin, cars[i].driver_name);
std::cout << "What is the color for car " << i + 1 << "? ";
std::getline(std::cin, cars[i].color);
std::cout << "What is car number for car " << i + 1 << "? ";
std::cin >> cars[i].number;
std::cout << "What was the laptime for car " << i + 1 << "? ";
std::cin >> cars[i].t_minutes >> cars[i].t_seconds;
std::cin.ignore(1000, '\n');
std::cout << "\n";
}
// print out info
for (int i = 0; i < SIZE; i++)
{
std::cout << cars[i].color << std::endl;
std::cout << cars[i].number << std::endl;
std::cout << cars[i].t_minutes << ":" << cars[i].t_seconds << std::endl;
std::cout << "\n";
}
return 0;
}
I need help that is what I thought this site was for. If you can help me then thank you if not then please keep your opinion to yourself. I am struggling and am trying to get help as quickly and efficiently as possible. Any advice you might have is appreciated. I am not trying to waste anyone's time.
I am struggling and am trying to get help as quickly and efficiently as possible.
In which case, you should follow the advice AbstractionAnon gave you. Making multiple threads on the same topic is the exact opposite of efficient. It fragments the discussion on your topic, making it less productive and helpful for you.
It also wastes our time, as well as yours, as people may try and and answer you on one thread, when the same answer has already been given on another. You're not the only person here, and other peoples' time is no less valuable than yours.
Also, if you're going to be rude and belligerent towards the users on this forum, do you honestly think that's going to make people want to help you?