
Het P.
asked 03/30/21MAKING A program in c#
Business Requirements
Create a program that will print out a customized oil change schedule for a car buyer based on the car’s starting mileage for the next 3 years based on the rules set out by the dealership and the users estimated miles per year input. Here’s the guide needed to print the schedule:
First Oil Change | 10,000 miles |
Oil Change | Every 5,000 miles after 10,000 miles |
Tire Rotation | Every 10,000 miles |
60K Full Check, Oil Change, Filters | 60,000 miles |
100K Full Check, Oil Change, Tire Rotation, belts | 100,000 miles and every 50,000miles after |
*Cars start with an oil change at purchase
Goal
· Gain experience using loops. There should be a loop iterating over the maintenance every 5000 miles to determine if the user needs maintenance and it should make sure it does this for an estimated 3 years worth of mileage based on the user’s input of miles per year
· Gain experience using conditionals. There should be checks with each time through the loop to see what sort of maintenance would be needed at this interval.
Inputs
Starting mileage, estimated miles per year
What to print to console
· A header line listing Mileage and Maintenance. Format with enough width so that everything lines up and is left aligned like the table above.
· A row for each maintenance necessary for this car.
o The table should start with maintenance necessary for this car based on its mileage. In other words, if the car starts with 50,000 miles, don’t show the first oil change or any oil change that would occur with 50,000 miles.
o Note, cars will have actual mileage like 35462 not rounded up by the thousands, so 5,000 miles after 35462 is when the next oil change should occur 40,462 so that’s what shows up in the mileage column for that row.
o Your table will show the exact mileage for each maintenance. It won’t have rows like mine above that say every 10,000 miles. You are calculating that.
o Allow enough space to make everything line up in columns by using the format tag.
1 Expert Answer

Patrick B. answered 03/30/21
Math and computer tutor/teacher
/******************************************************************************
Online C# Compiler.
Code, Compile, Run and Debug C# program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
using System;
class HelloWorld {
static void Main() {
Console.Write("Please input the starting mileage :>");
string inbuff = Console.ReadLine();
long starting_mileage = long.Parse(inbuff);
Console.Write("Please input the miles per year :>");
inbuff = Console.ReadLine();
int miles_per_year = int.Parse(inbuff);
long stopping_mileage = starting_mileage + 3*miles_per_year;
//Console.WriteLine(starting_mileage + " : " + miles_per_year + " : " + stopping_mileage);
long cur_mileage = starting_mileage;
bool one_shot_60k = (starting_mileage<60000);
bool one_shot_100k = (starting_mileage<100000);
bool tire_rotation= false;
bool full_svc_flag = false;
long full_svc_mileage=100000;
Console.WriteLine(" MILEAGE MAINTENANCE ");
while (cur_mileage<stopping_mileage)
{
cur_mileage += 5000;
Console.WriteLine(cur_mileage + " OIL CHANGE ");
if (tire_rotation)
{
Console.WriteLine(cur_mileage + " TIRE ROTATION ");
}
tire_rotation = !tire_rotation;
if (one_shot_60k)
{
if (cur_mileage>=60000)
{
Console.WriteLine(cur_mileage + " FULL CHECK,Oil Change,Filters ");
one_shot_60k=false;
}
}
if (full_svc_flag)
{
if (cur_mileage>=full_svc_mileage)
{
Console.WriteLine(cur_mileage+ " FULL CHECK,Oil Change, Tire Rotation,Belts");
full_svc_mileage = cur_mileage+50000;
}
}
if (one_shot_100k)
{
if (cur_mileage>=100000)
{
Console.WriteLine(cur_mileage+ " FULL CHECK,Oil Change, Tire Rotation,Belts");
full_svc_flag=true;
full_svc_mileage = cur_mileage+50000;
one_shot_100k=false;
}
}
} //while
}
}
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
No the columns do not line up ... I am leaving that FOR YOU to fix. You may also change the name of the class. I used the online C# compiler.03/30/21