Win a copy of Functional Design and Architecture this week in the Functional programming forum!

Chris Caretti

+ Follow
since Jul 15, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Caretti

Many thanks for your help. It really helped me think it through more clearly. Below is where I have got to. Do you think this is succinct enough based on the parameters I was required to work within?

One final thing, I have noticed that if the user enters an incorrect choice, then whilst a message can be displayed it doesn't return them to the preceding question? is this because I'm missing something, or the way the if..else is nested?

13 years ago
Yes, your questions mirror my desire exactly. However, my ability so far and lack of understanding have led me to follow the wordy route I've currently arrived at!
13 years ago
Thank you for your advice so far, and I have been attempting to understand where I am going wrong. Below is my latest attempt. I am using both if..else and switch, but am not sure if I have set the costs in the best way. Also it does not end the right way on some selections. It is going back to the earlier question on extras.

I guess my two questions here are, how should I be incorporating the else part so the total cost is delivered at the end? And secondly, is there a better way to establish those costs in the first place?

13 years ago
Thank you for directing me to the Beginners FAQ. Quite right too! I understand that you wish to see whether I have spent some time on this and tried to construct it myself.

Below is approx. my 8th attempt. I certainly don't wish anyone to provide me with the answer, just some clarity on working through this kind of problem.

I have decided that I want to try and make it work with if..else (and will then use switch once I have understood), so I learn to break down the logical steps properly.

I have been attempting as below. But each time I try it, I can't get it to work so that a value is retained and then all added together at the end.

<pre name="code" class="core">package ordersystem;

import java.util.*;

public class OrderSystem {

public static void main(String[] args) {

int screens;
double priceDVD, pricePrinter, price38, price43, subTotal, priceTotal;
char reply;

Scanner sc = new Scanner(;
System.out.println("Choose your screen size (38/43) ");
screens = sc.nextInt();

price38 = 451.98;
price43 = 475.98;

if (screens == 38) {
System.out.println("Thank you, your subtotal is:� " + 451.98);
} else if (screens == 43) {
System.out.println("Thank you, your subtotal is:� " + 475.98);

System.out.println("Would you like extras?(y/n)?");
reply =;

priceDVD = 65.99;
pricePrinter = 125.00;

if (reply == 'y') {
System.out.println("Please select from the following");
System.out.println("[1] DVD at �65.99");
System.out.println("[2] Printer at �125.00");
System.out.println("[3] DVD and Printer at �190.99");

reply =;

if (reply == '1') {
System.out.println(" ")

[edit]Add Code Tags. CR[/edit]
[ July 16, 2008: Message edited by: Campbell Ritchie ]
13 years ago
I am very early into studying Java and using a book called "Java in Two Semesters - 2nd Ed". The early exercises don't have answers and I have been attempting a short programming exercise without success. I do not understand how to build in selection that can be pulled together as a total at the end. The chapter was covering if..else and switch.

Could someone please provide the pseudocode to the following as this might help me work it out?

"Write a program to take an order for a computer system. The basic system costs 375.99. The user then has to choose from a 38cm screen (75.99) or a 43cm screen (99.99). There are also two optional extras DVD/CD Writer (65.99); Printer (125.00). Allow the user to select from these extras and then display the final cost of the order."
13 years ago