❔ New to C# and want help with the last part of my assignment
Write a C# console application program: Shopping cart program
Question:
You have an online store selling fruits. First, you have to ask user input name, phone number, address, and email. Second, you have to display the menu on the screen.
Oranges $2, Apples $3, tomatoes $5, bananas $0.5, pears $10, grapes $4.8
*Then, the program asks the user how many does the user want for each item and calculate the subtotal.
Final, you have to show items and the subtotal before tax, tax, and total on the screen and display user’s information and thank you messages at the end.
The part I need help with is calculating the subtotal and subtotal + tax
to my understanding i need o create a object method inside of FruitCost.cs in order to calculate the total price and print it out to the user but the multiple ways ive tried it never returns the total correctly or I'm given an error.
P.S
other classes and work have taken up a lot of time so im rushing to get this done
4 Replies
i dont really understand the question but there are several ways to make the structure better. you can create Dictionary<string, double>() which will contain the data and be your database. then you can create a Basket or Stack or something that will hold these and this class will have method to calculate total with or without tax. if you want to do it in real OOP way, you can create a class or interface Fruit (or Item if you have not only fruits for choice) and for every fruit/item create its own class. that way you dont need a database because you will have the data inside classes.
Well what have you tried exactly? You are very close. Just a few lines left
no worries i was finally able to get it
I was overthinking it and after stepping away for a minute I was able to figure it out
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.