Create a console program that will perform the following:
• Ask the user to enter the pieces of apple.
• Ask the user to enter the total price of the apple(s).
• Print the total price of the entered pieces of apple(s).
• Convert the entered price into a whole number, then display the values of the original
price and the converted price.
2. Name the project as DataTypesApp and the class as DataTypesProgram
using System;
namespace DataTypesApp
{
class DataTypesProgram
{
public static void Main(string[] args)
{
double price, totalprice;
int apple;
Console.Write("Enter the pieces of apple: ");
apple = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the price of the apple(s): ");
price = Convert.ToDouble(Console.ReadLine());
totalprice = price * apple;
Console.WriteLine();
Console.WriteLine("Total price of the entered pieces of apple(s): {0}", totalprice);
Console.WriteLine("Original price: {0}", price);
Console.WriteLine("Converted price: {0}", (int)price);
Console.WriteLine();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment