|
| |||||||
![]() | Welcome to iWEBTOOL Talk, where you talk about
webmaster-related stuff.
1 Register
2 Browse the board
3 Discuss whatever may interest you! | |||||||||||||
![]() |
| | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Newcomer Join Date: May 2007
Posts: 2
![]() | i have 2 little programs that im stuck on. the first, i need to out put all three numbers from highest to lowest but i can only get it to out put the one largest number and not the other two as well. the other program im stuck on is trying to get "quit" to exit when equal to "y" and loop back if not "y" "Y" "n" "N". it dosen't even have to loop really. any help would be greatly appreciated import cs1.Keyboard; public class order { public static void main (String[] args) { int number, number2, number3; System.out.println("Enter number 1"); number = cs1.Keyboard.readInt(); System.out.println("Enter number 2"); number2 = cs1.Keyboard.readInt(); System.out.println("Enter number 3"); number3 = cs1.Keyboard.readInt(); if (number > number2 && number > number3) { System.out.println (number); } if (number2 > number3 && number2 > number ) { System.out.println (number2); } else System.out.println (number3); } } import cs1.Keyboard; public class converter { public static void main (String[] args) { int option; double Pound, Currency; String quit; do { System.out.println("Please enter GBP amount:"); Pound = cs1.Keyboard.readInt(); System.out.println("Please pick one of the four options:"); System.out.println("1 = Euro"); System.out.println("2 = USD "); System.out.println("3 = AUD "); System.out.println("0 = Quit"); option = Keyboard.readInt(); if (option == 1) { Currency = Pound * 1.48; System.out.println("Answer =" +Currency); System.out.println("Do you wish to quit the programme? "); System.out.println("Y or N "); quit = cs1.Keyboard.readString(); do if(quit != "y") if(quit != "Y") if(quit != "n") if(quit != "N") System.out.println("try again"); while (!(quit == "y")); System.out.println("You have quit the programme"); } else if (option == 2) { Currency = Pound * 1.97; System.out.println("Answer =" +Currency); } else if (option == 3) { Currency = Pound * 2.43; System.out.println("Answer =" +Currency); } } while (!(option == 0)); System.out.println("You have quit the programme"); } } |
| |
|
| |||||||
| | #2 |
| Member Join Date: Mar 2007
Posts: 148
![]() | this part of the code is wrong.. the logic of your conditional statements is wrong. Code:
and so is this.. you have to put the process you want repeated inside the do-while loop and there is no need for these lines (if(quit != "y")if(quit != "Y")if(quit != "n")if(quit != "N")). Code:
__________________ |
| |
| | #3 |
| Newcomer Join Date: May 2007
Posts: 2
![]() | thx for the reply. so my logic is messed up then : ( what can i say, im no vulcan. what should the logic be then? |
| |
(Threads which have no activity for more than 30 days are automatically closed.) |
| Quick Reply | ||
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If you stuck in sandbox ,watch this ,will help you | kijakarn | General Talk | 3 | 04-03-2007 03:30 PM |
| Affiliate Programs - I need some good advice. | ev8321 | Marketing and Promotion | 19 | 02-09-2007 10:57 PM |
| *Majorly STUCK!* Professional NEEDED!!! | lip9000 | PHP | 3 | 10-11-2006 04:29 PM |
| Suggested Cpc programs? | MrAlan | Marketing and Promotion | 2 | 10-02-2006 05:00 AM |
| Paltalk Programs | webmasterran | Advertise your website | 0 | 08-23-2006 04:06 PM |