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
For how long should a media piece hold the user's attention?
Nastasia [14]

Answer:

C) until the message has been communicated

5 0
3 years ago
Read 2 more answers
Now you are ready to implement a spell checker by using or quadratic. Given a document, your program should output all of the co
Harlamova29_29 [7]

Answer:

Sorry po idont know po ehhh sorry

5 0
2 years ago
How are switches indirectly involved in ARP poisoning?
11Alexandr11 [23.1K]

Answer:

They

are indirectly involved in the attack because they do not verify the the MAC/IP address

association

Explanation:

PLEASE MARK ME AS BRAINLIEST

8 0
3 years ago
Unit testing:_________. A. provides the final certification that the system is ready to be used in a production setting. B. incl
NARA [144]

Answer:

Option (C) is the correct option to the following question.

Explanation:

The following option is correct because the unit testing is the process of testing a single unit of software at a time, which means the testing of each and every program separately.

In simple words, Unit testing a process of testing in which the developer executes the single method or a function, statements or loop in the program of the software to checking is it working fine or not.

7 0
2 years ago
What is seven times seven divided by 49
Travka [436]

The answer is really simple. 7 x 7 = 49. 49/49 is 1. I hope this helps

6 0
3 years ago
Read 2 more answers
Other questions:
  • would specify that only selected members of the payroll and human resources department would have the right to change sensitive
    11·1 answer
  • What are the desirable qualities of a Product Vision?
    11·1 answer
  • The Freemont Automobile Factory has discovered that the longer a worker has been on the job, the more parts the worker can produ
    11·1 answer
  • J. A computer on a network that acts as the central storage location for
    5·1 answer
  • 2. From the listing code, please give the block of line numbers for code which are concerned with the following: A) Main functio
    5·1 answer
  • How can i change my age on my profile here bc i am 13 but i accidenlty put 2005 instead of 2006 no need to rush to answer just w
    9·2 answers
  • According to the video, what kinds of projects would Computer Programmers be most likely to work on? Check all that apply.
    13·2 answers
  • How many of you got the right answer from this app​
    8·1 answer
  • Describe how data is transmitted using half-duplex serial data transmission.
    9·1 answer
  • what option can be used to create vpn connections that can be distributed to users' computers so that vpn clients do not have to
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!