Answer to Question #304873 in C# for hannat

Question #304873

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.




1
Expert's answer
2022-03-02T08:20:28-0500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter pieces of apple: ");
            int pieces = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Please total price of the apple(s): ");
            decimal price = Convert.ToDecimal(Console.ReadLine());

            decimal totalPrice = pieces * price;
            Console.WriteLine("Total price: {0}", totalPrice);
            decimal convertedTotalPrice = Math.Truncate(totalPrice);

            Console.WriteLine("Original price: {0}, converted price: {1}", totalPrice, convertedTotalPrice);

            Console.ReadKey();
        }
    }
}

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