how do I make this in c# if the charges are $20 per day plus 25 cents per mile
how do I make this in c# if the charges are $20 per day plus 25 cents per mile.
using System;
class HelloWorld
{
static void Main() // Main function
{
Console.Write("Enter the number of days: "); // asking user to enter the no. of days
int days = Convert.ToInt32(Console.ReadLine()); // taking the no. of days from user
Console.Write("Enter the number of miles driven: "); // asking user to enter the no. of miles
int miles = Convert.ToInt32(Console.ReadLine()); // taking the no. of miles from user
// 1$ = 100 cents ; so, 1 cent = 1/100 $
double cost = (days * 20) + ( (double) miles * 25 / 100); // calculating cost
// display output
Console.Write("If you rent a car for "+ days +" days and drive "+ miles +", your rental fee is $"+ cost );
}
}
Step by step
Solved in 3 steps with 3 images