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
Can someone help me so I don’t fail this class:(
charle [14.2K]

Answer:

Whatcha need help with?

Explanation:

4 0
3 years ago
The discipline of building hardware architectures, operating systems, and specialized algorithms for running a program on a clus
kondaur [170]

The discipline of building hardware architectures, operating systems, and specialized algorithms for running a program on a cluster of processors is known as <u>parallel computing.</u>

<u></u>

<h3>What is Parallel Computing?</h3>

Parallel computing refers to the process of breaking down larger problems into smaller, independent, often similar parts that can be executed simultaneously by multiple processors communicating via shared memory, the results of which are combined upon completion as part of an overall algorithm. The primary goal of parallel computing is to increase available computation power for faster application processing and problem solving.

<h3>Types of parallel computing</h3>

There are generally four types of parallel computing, available from both proprietary and open source parallel computing vendors:

  • Bit-level parallelism: increases processor word size, which reduces the quantity of instructions the processor must execute in order to perform an operation on variables greater than the length of the word.
  • Instruction-level parallelism: the hardware approach works upon dynamic parallelism, in which the processor decides at run-time which instructions to execute in parallel; the software approach works upon static parallelism, in which the compiler decides which instructions to execute in parallel.
  • Task parallelism: a form of parallelization of computer code across multiple processors that runs several different tasks at the same time on the same data.
  • Superword-level parallelism: a vectorization technique that can exploit parallelism of inline code.

Learn more about parallel computing

brainly.com/question/13266117

#SPJ4

5 0
1 year ago
Which type of network is created when you use encrypted tunnels between a computer or a remote network and a private network thr
Deffense [45]
<span>Virtual private network (VPN) is the answer</span>
3 0
3 years ago
Why is it not advisable to mark tlc plates with a pen to indicate?
nikitadnepr [17]
The plate can change the function that is in it. If you were to name it wrong, you would have to debug the code and possibly rewrite it.
3 0
3 years ago
The default view in word is ____ view, which shows the document on a mock sheet of paper in the document window.
dolphi86 [110]
<span>I'm pretty sure that the answer is: The default view in word is print layout view, which shows the document on a mock sheet of paper in the document window.</span>
7 0
3 years ago
Other questions:
  • What is the last step in conducting url search
    11·1 answer
  • If r is an instance of the above Person class and oddNum has been declared as a variable of type boolean, which of the following
    8·1 answer
  • 1. JAVA Create one method to do the following expressions. Given the following declarations, what is the result of each of the e
    13·1 answer
  • The set of instructions that directs the computer to perform a variety of tasks is known as a
    9·1 answer
  • How would Microsoft Word inform you of the error in the sentence below? (Tip: The error is in bold.)
    7·1 answer
  • What is the first step to creating a PivotTable?
    11·1 answer
  • The fossil record is usually incomplete due to the destruction of fossils.
    10·1 answer
  • If you were to create a new app for a smartphone or tablet that does not already exist, what would you create?
    10·1 answer
  • Assume the existence of an UNSORTED ARRAY of n characters. You are to trace the CS111Sort algorithm (as described here) to reord
    14·1 answer
  • Which of the following is NOT an example of soft skill?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!