Question

In: Computer Science

Shopping Cart App (C#) Please create a C# Console (.NET Framework) application which reads from the...

Shopping Cart App (C#)

Please create a C# Console (.NET Framework) application which reads from the user, the price of items in their shopping "cart". Be sure to tell the user how to stop (or ask them if they want to stop) entering prices.

Items can be priced any positive number greater than zero.

When the user has entered the prices for all items in their "cart", calculate the subtotal (the sum of all item prices).

Next, check if the user is a member of our Frequent Shopping Club. If so, take 10% off the subtotal price.

Finally, calculate the tax owed (the tax RATE is 4.5%), and then the total (subtotal + tax OWED = total).

Display the subtotal, discount (will be zero if not a member of the Frequent Shopping Club), tax owed, and total.

You should use While loops, IF statements, and TryParse statements to ensure all input is correctly entered.

Solutions

Expert Solution

If you have any doubts, please give me comment...

using System;

public class ShoppingCart{

    public static void Main(){

        char choice = 'Y';

        char isFSCMember;

        double price, discount=0, sub_total = 0, tax_owed, total;

        while(choice=='Y' || choice=='y'){

            Console.Write("Enter price of item: ");

            Double.TryParse(Console.ReadLine(), out price);

            if(price<0)

                Console.WriteLine("Price can't be negative");

            else

                sub_total += price;

            Console.Write("Do you want to continue(Y/N): ");

            choice = Console.ReadKey().KeyChar;

            Console.WriteLine();

        }

        Console.Write("Are you member of our Frequent Shopping Club(Y/N)? ");

        isFSCMember = Console.ReadKey().KeyChar;

        Console.WriteLine();

        if(isFSCMember=='Y' || isFSCMember=='y')

            discount = sub_total*0.10;

        sub_total -= discount;

        tax_owed = sub_total*(4.5/100);

        total = sub_total + tax_owed;

        Console.WriteLine("Subtotal: ${0}", sub_total.ToString("0.00"));

        Console.WriteLine("Discount: ${0}", discount.ToString("0.00"));

        Console.WriteLine("Tax Owed: ${0}", tax_owed.ToString("0.00"));

        Console.WriteLine("Total: ${0}", total.ToString("0.00"));

    }

}


Related Solutions

write a c# console application app that reads all the services in the task manager and...
write a c# console application app that reads all the services in the task manager and automatically saves what was read in a Notepad txt file.  Please make sure that this program runs, also add some comments
1-Create a new Visual C# Console App (.NET Framework). Name the solution "GPA Calculation". 2-Zip and...
1-Create a new Visual C# Console App (.NET Framework). Name the solution "GPA Calculation". 2-Zip and Submit your entire project with the solution file GPA Ask the user to input their grade percentage (e.g. the use will enter 98 if they had an overall grade of 98% in their course) for their Accounting, Marketing, Economics and MIS courses. Assume each course is worth 3 credit hours. Once you have all of their grades output what letter grade they earned for...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
Create a simple shopping cart application. Ask the user to input an item number and quantity....
Create a simple shopping cart application. Ask the user to input an item number and quantity. Update the shopping cart. Display the updated cart. Include the following when displaying cart: item number, name, quantity and total price. Ask for another update or end the program. Design Requires 2 classes: the main class and the cartItem class In the main class: Need one array named cartArray of type cartItem. Size = ? Need a loop that asks the user for input....
Create a simple shopping cart application. Ask the user to input an item number and quantity....
Create a simple shopping cart application. Ask the user to input an item number and quantity. Update the shopping cart. Display the updated cart. Include the following when displaying cart: item number, name, quantity and total price. Ask for another update or end the program. Design Requires 2 classes: the main class and the cartItem class In the main class: Need one array named cartArray of type cartItem. Size = ? Need a loop that asks the user for input....
IN C# lang Write a console app (review Module 5 for console app) that stores 3...
IN C# lang Write a console app (review Module 5 for console app) that stores 3 students test stores in 3 separate arrays as integers. Some did not not take all the tests, so they each have a their own length and we use separate arrays. Declare and initialize each array. Use meaningful names. Print each array as follows: Morgan 98, 72, 65 Bowie 15, 47, 35, 92, 94 Ananya 91, 68, 87, 75 Extra credit: Compute the average for...
C# Create a console application that prompts the user to enter a regular expression, and then...
C# Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a regular expression...
with C# create a console application project that outputs the number of bytes in memory that...
with C# create a console application project that outputs the number of bytes in memory that each of the following number types use, and the minimum and maximum values they can have: sbyte, byte, short, ushort, int, uint, long, ulong, float, double, and decimal. Try formatting the values into a nice-looking table! More Information: You can always read the documentation, available at https://docs.microsoft.com/en-us/dotnet/standard/base-types/composite-formatting for Composite Formatting to learn how to align text in a console application. Your output should look...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
Needs to be written in C# Console App! Create a base class BankAccount. Decide what characteristics...
Needs to be written in C# Console App! Create a base class BankAccount. Decide what characteristics are common for checking and saving accounts and include these characteristics in the base class. Define derived classes for checking and savings. In your design , do not allow the banking base account to be instantiated --only the checking and saving classes. Use a Program class to test your design.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT