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]
4 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]4 years ago
4 0

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

Download docx
You might be interested in
What field in an IPv4 packet is altered to prioritize video streaming traffic over web surfing traffic?
Serhud [2]

Answer:

DiffServ (Differentiated Service)

Explanation:

DiffServ (Differentiated Service) field is used to prioritize traffic in IPv4 packet.

DiffServ is used as QoS (quality of service) on networks at Layer 3, replacing former IPv4 TOS field to effectively deal with the web traffic and prioritization issues starting from 1998.

3 0
4 years ago
The number of pixels that can be displayed on the screen at one time is known as what? screen resolution. viewing angle. color d
nevsk [136]

Answer:

screen resolution

Explanation:

The screen resolution indicates the number of pixels that can be displayed at one time on a given screen. For example, it could be numbers like 1920x1080, 1600x900 and so on.

Viewing angle has nothing with the pixel count, although viewing port would.  Color depth concerns the number of colors you can display at one time.  Pixel density is the concentration of pixels, like in Apple's retina display, that increases the number of pixels in the screen, but that doesn't give you the information on how many there are.

6 0
3 years ago
Which guideline should you follow when selecting the font for a presentation?
diamong [38]
Most teachers prefer you to use Arial or Times New Roman
3 0
4 years ago
The application window controls include: minimize, maximize, and close<br><br> A) true <br> B) false
Arlecino [84]

Answer:

True

Explanation:

Look at the top right of your computer while having a chrome tab open. You will see a line, a box, and a x. Hover over each and you can see the names.

6 0
3 years ago
The instant pivot button is displayed in the statistics and visualization tabs when a _______ search is run.
Arisa [49]

Answer:

<h2>The instant pivot button is displayed in the statistics and visualization tabs when a <u>non-transforming</u>  search is run. </h2>

Explanation:

<h3>Transforming Search:</h3>

It can be defined as a search in which transforming commands are used that involve, charts and stats to convert data of events that is gained by the search in to tables (statistical). These tables can further be used for the basis of visualizing data in the form of charts.

Non-Transforming Search:

The search that do no contains produce event lists that can be viewed in Events tab. while using non-transforming search, i we want to generate tables or charts we must follow the points below:

  • Click ob statistics and Visualization tab.
  • Select pivot to open the search.
  • All the visualizations can be generated in this editor.

<h2>i hope it will help you!</h2>
5 0
4 years ago
Other questions:
  • Which PowerShell command will upgrade the VM configuration version to take advantage of the new features in Windows Server 2016?
    12·1 answer
  • Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an
    5·1 answer
  • A(n) Answer display color uses the least electricity when compared to any other color.
    15·1 answer
  • Chief technology officers can influence a company's current and future ____.
    9·1 answer
  • Cuales son las paginas web​
    12·1 answer
  • Prime numbers can be generated by an algorithm known as the Sieve of Eratosthenes. The algorithm for this procedure is presented
    8·1 answer
  • Reverse Word Order: Write a program that reverses the order of the words in a given sentence. This program requires reversing th
    15·1 answer
  • What is the difference between autofocus and autocomplete
    8·1 answer
  • The physical parts of a computer are called application software.
    9·2 answers
  • When you _______ the top row or the left column, you can keep column headings and row labels visible as you scroll through your
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!