1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ehidna [41]
3 years ago
14

Create a Trip class. Include as data members destination, distance traveled, total cost of gasoline, and number of gallons consu

med. Include appropriate constructors and properties. Add additional methods that calculates miles per gallon and the cost per mile. Override the ToString ( ) method. Create a second class to test your Trip class
This is what I have so far... I'm not sure if I'm using the appropriate constructors and properties per the instructions. Thanks.

class Program
{
static void Main(string[] args)
{
double totalMiles, totalGallons, pricePerGallon;
string destination

getInput(out destination, out totalMiles, out totalGallons, out pricePerGallon);

// Calculate results
double milesPerGal, costPerMile, totalTripCost;

milesPerGal = calculateMpg(totalMiles, totalGallons);

totalTripCost = calculateTrip(pricePerGallon, totalGallons);

costPerMile = calculateCost(totalTripCost, totalMiles);

// Print results
printOutput(milesPerGal, costPerMile);
Console.ReadLine();
}

//calculate miles per gallon, cost per mile, and total gas cost
static double calculateMpg(double totalMiles, double totalGallons)
{
double milesPerGal;
milesPerGal = totalMiles / totalGallons;
return milesPerGal;
}

static double calculateCost(double totalTripCost, double totalMiles)
{
double costPerMile;
costPerMile = totalTripCost / totalMiles;
return costPerMile;
}

static double calculateTrip(double pricePerGallon, double totalGallons)
{
double costPerMile;
costPerMile = pricePerGallon * totalGallons;
return costPerMile;
}

//accept input from user
static void getInput(out string dest, out double miles, out double gallons, out double unitPrice)

{
Console.Write("Enter destination: ");
destination = (Console.ReadLine());

Console.Write("Enter total miles traveled: ");
miles = double.Parse(Console.ReadLine());

Console.Write("Enter number of gallons of gas consumed: ");
gallons = Convert.ToDouble(Console.ReadLine());

Console.Write("Enter the gas price per gallon: ");
unitPrice = double.Parse(Console.ReadLine());
}

//print the calculated values
static void printOutput(double mpg, double cpm)

{
Console.WriteLine();

Console.WriteLine("Miles per Gallon: {0:F2}", mpg);
Console.WriteLine("Cost per mile: {0:C}", cpm);
Console.Read();
}
}
}
Computers and Technology
1 answer:
Luba_88 [7]3 years ago
4 0

The answer & explanation for this question is given in the attachment below.

Download docx
You might be interested in
Describe how you center text.
Annette [7]
On the bottom corner you can see something that looks like this:
|--- | -- | ---|
Click the middle one?
7 0
3 years ago
Read 2 more answers
After selecting the Slide Master tab (within the View tab), which actions can a user take to configure a slide master?
myrzilka [38]

Answer:

Yes those are the correct order.

Explanation:

5 0
2 years ago
11.
dsp73
11. <span><span>their population crashed.
</span><span>
12. </span></span><span>dead zone

13. I believe </span><span>energy efficient</span>
4 0
3 years ago
Read 2 more answers
Choose the missing term.
qaws [65]

Answer:

import

Explanation:

the <em>import </em>keyword is used to import external modules into a python script.

6 0
2 years ago
What type of control structure is the default method of the computer reading code?
Delicious77 [7]
The answer is Selection. Hope this helped you
8 0
3 years ago
Other questions:
  • Create a simple main() that solves the subset sum problem for any vector of ints. Here is an example of the set-up and output. Y
    12·1 answer
  • A virtual private network (VPN) is used to securely connect to another network over a insecure network.
    9·2 answers
  • Please Do Solve it guys...
    6·1 answer
  • You have a chart that shows 100 data points and you've circled the highest value. Which of the following are you using?
    8·1 answer
  • Which graph is the solution to the system 2x – 3 and y &lt; 2x + 4?
    5·2 answers
  • A major public university graduates approximately 10,000 students per year, and its development office has decided to build a We
    10·1 answer
  • Informed _________ will better manage complexities and enable more efficient manufacturing of goods.
    13·1 answer
  • Help plz (will give brainliest)
    9·1 answer
  • A leading global vendor Of computer software hardware for computer mobile and gaming systems and cloud services it's corporate h
    14·1 answer
  • A ____ is an Access feature that makes it easy to enter data.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!