subject

Create a Trip class. Include as data members destination, distance traveled, total cost of gasoline, and number of gallons consumed. 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();
}
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:30
Kyle, a receptionist for a building supply company, recently won an award for saving his company money on their phone system. after being presented with kyle's research, the company changed the way in which it made long-distance phone calls and cut their expenses in this area by 75 percent. the new system the kyle's company most likely adopted was wired communications switching stations voip hdtv
Answers: 3
question
Computers and Technology, 23.06.2019 00:20
The open systems interconnection (osi) reference model: defines standards for many aspects of computing and communications within a network. is a generic description for how computers use multiple layers of protocol rules to communicate across a network. defines standards for wireless local area network (wlan) communication protocols. details the advantages and disadvantages of various basic network cabling options.
Answers: 1
question
Computers and Technology, 23.06.2019 01:40
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
question
Computers and Technology, 23.06.2019 03:30
Many everyday occurrences can be represented as a binary bit. for example, a door is open or closed, the stove is on or off, and the fog is asleep or awake. could relationships be represented as a binary value? give example.
Answers: 1
You know the right answer?
Create a Trip class. Include as data members destination, distance traveled, total cost of gasoline,...
Questions
question
Physics, 03.03.2021 14:00
question
Mathematics, 03.03.2021 14:00
question
Computers and Technology, 03.03.2021 14:00
question
Physics, 03.03.2021 14:00
question
Mathematics, 03.03.2021 14:00
question
Mathematics, 03.03.2021 14:00
question
Mathematics, 03.03.2021 14:00
question
Mathematics, 03.03.2021 14:00
Questions on the website: 13722360