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
Please answer the following will mark brainiest except the first 3 rest all
ollegr [7]

Answer:

1) Standalone machine

2) Local

3) Either Wide area network(WAN) or a web

Done your first 3

6 0
3 years ago
A written document containing a description of a property as of the day of inspection is called a(n) 
meriva
D. An inspection report! Hope this helps!
5 0
3 years ago
How does the rhythm of "The Raven" compare to "Casey at the Bat?"
katen-ka-za [31]

Answer:

Casey at the Bat: A Ballad of the Republic Sung in 1888' is the full title of an American poem written by Ernest Lawrence Thayer. The poem tells the story of the final half-inning of a baseball game. ... Not only is it a love song to the dramatic sport of baseball, but it is a ballad to 'the Republic in 1888'.

8 0
3 years ago
Anyone wanna play Bloons tower defense 5 im rank 52
diamong [38]

Answer:

nah im good fam thanks for askin

Explanation:

8 0
3 years ago
Read 2 more answers
What lets you change the order of events in a game?
IRISSAK [1]
B the story board editor.
8 0
3 years ago
Other questions:
  • How could the provisions in the new health reform bill improve access to care?
    14·1 answer
  • Identify the correct software or hardware applications in the passage below
    10·1 answer
  • DOES ANYONE KNOW HOW TO CHAGE THE IP ON A COMPUTER?
    8·1 answer
  • How can ascii be used to represent characters in computer system
    7·1 answer
  • 1.the following code example would print the data type of x, what data type would that be?
    12·1 answer
  • Declare a char array named line of size 50, and write a statement that reads in the next line of console input into this array.
    6·1 answer
  • Which administrative tool can you use to check your computer's health or troubleshoot problems with the operating system or soft
    11·2 answers
  • SOMEONE PLEASE HELP ME I REPOSTED THIS 3 time and no ONE HAD HELPED ME
    15·1 answer
  • Tascake Gets Free Brainliest Because he didnt get it<br><br> Tascake Heres Brainliest
    6·2 answers
  • What is composition
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!