In: Computer Science
I am a travel agent, I book in-city ride tickets and also ship your luggage to the next destination. 1-NYC All Around Town it is $29.00 2-Big Bus NYC Tour it is $49.00 3-NYC one day guided Sightseeing Tour it is $89.00 4-Circle Line Complete Manhattan Island Cruise is $44.00 5-Viator VIP: Empire State Building, Statue of Liberty and 9/11 Memorial is $129.00 I also provide a quote for your shipment to be mailed to your next destination. In order to calculate our quote, we need to know the total weight of the shipment in pounds, the distance in miles and whether or not there are hazardous materials in the shipment (e.g. batteries). The calculation for the quote is as follows: Quote = .65 * # of miles + .83 * # of pounds If there is hazardous materials in the shipment, there is an extra cost of .20 * # of pounds If the distance for the delivery is less than 150 miles and the total weight for the shipment is greater than 500 pounds, then there should be a 10% discount off of the total quote. Create a c# console app using conditional statement
IDE used: Online compiler onlinegdb.com
Program
using System;
public class TravelAgency {
public static void Main() {
//variables for weight, distance, quote,
discount
double weight,distance,quote,discount;
//string to get if hazardous material or
not
string hazard;
//get distance and weight
Console.WriteLine("\nEnter total Distance: ");
distance=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("\nEnter total weight: ");
weight=Convert.ToDouble(Console.ReadLine());
//ask if any hazardous material
Console.WriteLine("\nIf any hazardous material?
(yes/no) :");
hazard=Console.ReadLine();
//if hazardous material get extra
charge
if(string.Compare(hazard,"yes")==0)
{
quote=(0.65*distance)+(0.83*weight)+(0.20*weight);
//check if distance less than 150 and
weight more than 500 give discount
if(distance<150.00 &&
weight>500.00)
{
Console.WriteLine("\nSince distance is less than 150 and weight is
more than 500 there is 10% discount ");
//calculate
discount
discount=0.1*quote;
Console.WriteLine("\nDiscount is :
"+string.Format("{0:.##}",discount)+
"dollars"); //string.format : two place
decimal
//calculate final quote
and print
quote=quote-discount;
Console.WriteLine("\nYour total quote is : "
+string.Format("{0:.##}",quote)+ " dollars");
}
else
{
Console.WriteLine("Your total quote is : "
+string.Format("{0:.##}",quote)+ " dollars");
}
}
//if no hazardous
material
else
{
quote=(0.65*distance)+(0.83*weight);
if(distance<150.00 && weight>500.00)
{
discount=0.1*quote;
quote=quote-discount;
Console.WriteLine("Your total quote is : "
+string.Format("{0:.##}",quote)+ " dollars");
}
else
{
Console.WriteLine("Your total quote is : "
+string.Format("{0:.##}",quote)+ " dollars");
}
}
}
}
Sample Output