Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# Project Indy 500 Race This project will create a Driver class that contains data and methods associated with race car drivers. A driver object

C# Project

Indy 500 Race

This project will create a Driver class that contains data and methods associated with race car drivers. A driver object should contain the following data:

Name

Rank

Car Number

Number of races

Total amount spent

A Driver object should know how to return it's formatted data with a ToString method and will calculate the average cost per race by dividing the total amount spent by the number of races.

Data

Our data will come from a point in time during the race.

Testing

Our MainMethod will use hard-coded values obtained from our test data to create Driver objects. Different constructors will be tested and we will test our methods by setting data values and using our methods.

Create the required Driver class. The MainMethod has been supplied as a tester.

Our expected output is formatted. Each output item is formatted to be 24 units wide (23 for currency formatting). You may need to use the string.Format( ) method to produce this output: (see below)image text in transcribedimage text in transcribed

Here is the main.cs code:

using System;

using System.Console;

class MainClass {

public static void Main (string[] args) {

Driver tony = new Driver("Tony Kanaan", 1, 14, 40, 500000);

WriteLine(tony.ToString());

Driver driverTwo = new Driver("Scott Dixon");

WriteLine(driverTwo);

driverTwo.Rank = 2;

driverTwo.CarNo = 9;

driverTwo.NumRaces = 200;

driverTwo.TotalSpent = 4000000;

WriteLine("Driver two has spent an average of " + driverTwo.CalcAvgCost());

WriteLine(driverTwo);

}

}

//1 Tony Kanaan 14 00:39.5099 19 227.791 38 --.---- --.----

//2 Scott Dixon 9 00:39.8787 6 225.684 38 0.3688 0.3688

//3 Marco Andretti 98 00:39.9610 11 225.22 30 0.4511 0.0823

//4 Sebastien Bourdais 18 00:40.0329 5 224.815 43 0.5230 0.0719

//5 Charlie Kimball 23 00:40.0512 5 224.712 42 0.5413 0.0183

//6 Takuma Sato 30 00:40.1637 7 224.083 38 0.6538 0.1125

Driver Stats Driver Name Driver Rank Driver Car Num Races $$$ Spent Driver Stats Driver Name Driver Rank Driver Car Num Races $$$ Spent Driver two has spent an average of 20000 Driver Stats Driver Name Driver Rank Driver Car Num Races $$$ Spent Tony Kanaan 40 $500,000.00 Scott Dixon $0.00 Scott Dixon 9 200 $4,000,000.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago