You are going to the Rogers Centre to watch a baseball game. The aroma from
a hot dog cart catches your attention. Hot dogs are $2.50 each. Write a program
that asks you how much change you have in your pocket. If you have enough to
buy a hot output “Grab a hot dog.” In either case, output “Enjoy the game!” Test
your program using the values $2.00 and $3.00.
using System;
namespace App
{
class Program
{
static void Main(string[] args){
//asks you how much change you have in your pocket. If you have enough to
//buy a hot output "Grab a hot dog." In either case, output "Enjoy the game!"
Console.Write("How much change you have in your pocket? ");
double change = double.Parse(Console.ReadLine());
if (change >=2.5)
{
Console.WriteLine("Grab a hot dog");
}
else
{
Console.WriteLine("Enjoy the game!");
}
Console.ReadLine();
}
}
}
Comments
Leave a comment