Code:
namespace Extra_Practice_Mid_Term
{
class Program
{
static void Main(string[] args)
{
Register GasCo = new Register();
Console.WriteLine("Enter your credit card number");
int credit = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Choose one of the following grades of gas,");
Console.WriteLine("1. Regular(87)- $3.25/gallon");
Console.WriteLine("2. Mid(89)- $3.45/gallon");
Console.WriteLine("3. Premium(93)- $3.65/gallons");
double gasGrade = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("How many gallons of gas would you like");
int numberOfGallons=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Would you like a car wash? Yes or No?");
string carWash = (Console.ReadLine());
Console.WriteLine("Would you like snacks? Yes or No?");
string snackQuestion =(Console.ReadLine());
Console.WriteLine("How many snacks would you like?");
int amountOfSnacks = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Would you like a drink? Yes or No?");
Console.ReadLine();
Console.WriteLine("How many drinks would like?");
int amountOfDrinks = Convert.ToInt32(Console.ReadLine());
double overallCost = GasCo.Calculations(amountOfSnacks, amountOfDrinks, gasGrade, numberOfGallons, overallCost);
Console.WriteLine("Your total today will be ${0}, thank you come again!", overallCost);
//desplays everything the the user needs to the screen
Console.ReadKey();
}
class Register
{
public double Calculations(int amountOfSnacks, int amountOfDrinks, double gasGrade, int numberOfGallons, double overallCost)
{
double snackCost= 1.5;
double drinkCost= 1.75;
double snackTotal= snackCost * amountOfSnacks;
double drinkTotal= drinkCost * amountOfDrinks;
double foodBill= drinkTotal + snackTotal;
double taxAmount= foodBill * .06;
double gasTotal= gasGrade * numberOfGallons;
return overallCost= gasTotal + foodBill + taxAmount;
// this does the math to figure out the total.
}
public double Gas(double gasGrade)
{
if (gasGrade == 1)
{
return gasGrade = 3.25;
}
if (gasGrade == 2)
{
return gasGrade = 3.45;
}
if (gasGrade == 3)
{
return gasGrade = 3.65;
}
else
{
return 0;
}
}
//determines how much to charge for gas
public int GoingToTheCarWash(string carWash, double gasGrade, int washPrice)
{
if (carWash == "yes")
{
if (gasGrade == 3)
{
return washPrice = 1;
}
else
{
return washPrice = 5;
}
}
if (carWash == "no")
{
return washPrice = 0;
}
else
{
return 0;
}
//shows how much
}
}
}
}
Comment