The book I am working from is called 'Java in 2 semesters- third addition' On chapter 3 I am doing an example (number 5) which I cannot make work so my understanding and logic must be all wrong!
The question wants me to write a program to take an order for a computer system. the basic system is for example £300. The user then has to choose from two different monitors at 2 separate prices. Then the user is prompted for optional extras say a dvd at £65.99 or a printer at £125. the user needs to select from these options then the program will display the total amount of the overall order.
I have tried writing this using nested if else.. and using switch. I am having issues with the selection of the multiple items storing the calculations and the final calculation of ALL items selected.
I split the program in two using price1 then price 2 but it will not compile as i have variables that need initializing. I understand why but have no thoughts on a better solution or things to try :(
I am not looking at any giving me the answer straight away in code I want to understand the logic and program flow so I can learn from what I am clearly doing wrong!!
This is a basic example and nothing fancy as it is early in the book and has only just gone through keyboard inputs if else.. case and switch so one of these must be the solution if I can think this through correctly.
Thanks
Aucun commentaire:
Enregistrer un commentaire