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
Audrey would like to save her document. She should choose the Save command from the _____. folder menu window directory
Damm [24]

Answer:

File folder

Explanation:

6 0
3 years ago
Someone please explain me this​
Ipatiy [6.2K]

Answer:

2×4×6×8× your body

Explanation:

your pottery × 2×4×6×8×10

7 0
3 years ago
Explain how can you protect your computer from malware
rosijanka [135]
Trend micro security for your Mac or pc or trend micro mobil security for your android or iOS Mobil device?

Hope this helps!
6 0
4 years ago
Read 2 more answers
Assume that k corresponds to register $s0, n corresponds to register $s2 and the base of the array v is in $s1. What is the MIPS
BlackZzzverrR [31]

Answer:

hello your question lacks the C segment so here is the C segment

while ( k<n )

{v[k] = v[k+1];

     k = k+1; }

Answer : while:

   bge $s0, $s2, end   # while (k < n)

   addi $t0, $s0, 1    # $t0 = k+1

   sll $t0, $t0, 2     # making k+1 indexable

   add $t0, $t0, $s1   # $t0 = &v[k+1]

   lw $t0, 0($t0)      # $t0 = v[k+1]

   sll $t1, $s0, 2     # making k indexable

   add $t1, $t1, $s1   # $t1 = &v[k]

   sw $t0, 0($t1)      # v[k] = v[k+1]

   addi $s0, $s0, 1

   j while

end:

Explanation:

The MIPS assembly code corresponding to the C segment is

while:

   bge $s0, $s2, end   # while (k < n)

   addi $t0, $s0, 1    # $t0 = k+1

   sll $t0, $t0, 2     # making k+1 indexable

   add $t0, $t0, $s1   # $t0 = &v[k+1]

   lw $t0, 0($t0)      # $t0 = v[k+1]

   sll $t1, $s0, 2     # making k indexable

   add $t1, $t1, $s1   # $t1 = &v[k]

   sw $t0, 0($t1)      # v[k] = v[k+1]

   addi $s0, $s0, 1

   j while

end:

4 0
3 years ago
Software that interprets commands from the keyboard and mouse is also known as the?
mel-nik [20]
Software that interprets commands from the keyboard and mouse is also known as the operating system.. Hope this helped
5 0
3 years ago
Other questions:
  • You are able to change the formatting of a table after it is inserted into a placeholder. True or false
    9·2 answers
  • What is statement used to communicate ones feelings in a nonconfrontational manner
    9·1 answer
  • Using the drop-down menus, correctly complete the sentences.
    5·2 answers
  • What is the function of the command prompt?
    8·1 answer
  • 4. What is the simplest way to permanently get rid of an unwanted file?
    12·1 answer
  • 1. We want to add a button to the tally counter in Section 9.2 that allows an operator to undo an accidental button click. Provi
    8·1 answer
  • Can someone help me with these questions it's for drivers ed
    10·1 answer
  • Shelbi likes to play video games on an old Nintendo video game system. No matter how old the cartridge, when she inserts it into
    11·2 answers
  • Read the steps in the process of making a video.
    5·2 answers
  • Write a function named days() that determines the number of days since January 1, 1900 for any data passed as a structure. Use t
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!