Answer to Question #304265 in C# for fred

Question #304265

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

1
Expert's answer
2022-03-04T06:31:47-0500
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);
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS