Results 1 to 5 of 5
- 03-09-2009, 12:50 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 22
- Rep Power
- 0
[SOLVED] Cant figure out why its erroring
Below I have to sets of code. My first code called Lab6 should use the second set of code called Foreign. When I compile Lab6 it errors out and I cant figure out why. Please help
Java Code:import java.util.Scanner; import java.text.NumberFormat; public class Lab6 { public static void main(String[] args) { String more = "Y"; Foreign exchange = new Foreign(); do { exchange.menu(); exchange.choice(); exchange.dollars(); exchange.vertical(); System.out.println("\n" + exchange); System.out.print("\nWould you like to enter another exchange? Y/N "); more = Keyboard.nextLine(); } while (Character.toUpperCase(more.charAt(0)) == 'Y'); } }Java Code:import java.util.Scanner; import java.text.NumberFormat; public class Foreign { private int choice; private String country; private double dollars, rate, amount; Scanner Keyboard = new Scanner(System.in); NumberFormat dollarFormat = NumberFormat.getCurrencyInstance(); public Foreign() { dollars = 0.0; rate = 0.0; amount = 0.0; country = "null"; } public void menu() { System.out.println("======================================================"); System.out.println(" Foreign Exchange Menu"); System.out.println("======================================================\n\n"); System.out.println("1. U.S. to Canada"); System.out.println("2. U.S. to Mexico"); System.out.println("3. U.S. to Japan"); System.out.println("4. U.S. to Euro"); System.out.println("0. Quit\n"); System.out.print("\nPlease enter your choice:"); } public void choice() { choice = Keyboard.nextInt(); } public int getchoice() { return choice; } public void dollars() { System.out.print("\nEnter the amount of U.S. Dollars you want to convert: "); dollars = Keyboard.nextDouble(); if (choice >= 1 && choice < 5) switch (choice) { case 1: rate = 1.2418; country = "Canadian Dollars"; break; case 2: rate = 14.5436; country = "Mexican Pesos"; break; case 3: rate = 88.9183; country = "Japanese Yen"; break; case 4: rate = 0.774078; country = "Euros"; break; default: System.out.println("======================================================"); System.out.println(" Please select 1 through 4 or 0 to quit: "); System.out.println("======================================================\n\n\n"); } amount = dollars * rate; } public void vertical() { System.out.println("\nCountry = " + country); System.out.println("Rate = " + rate); System.out.println("Dollars = " + dollarFormat.format(dollars)); System.out.println("Value = " + amount); } public String toString() { String line; line = country + " " + rate + " " + dollars + " " + amount; return line; } }Last edited by JDAWG; 03-09-2009 at 01:06 AM.
- 03-09-2009, 01:44 AM #2
Member
- Join Date
- Feb 2009
- Posts
- 22
- Rep Power
- 0
I figured it out thanks
- 03-09-2009, 02:45 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
When you comes with an error please send that error message to see for others as well. So they can comment on your code so easily. Running your code and see not make sense always.
And also you have working on the same code here, post in another thread. Much better to stick with the same thread unless they are different.
Anyway, you have solved the problem yourself. Really nice. So this is time to mark the thread solved.
- 03-09-2009, 03:31 AM #4
Member
- Join Date
- Feb 2009
- Posts
- 22
- Rep Power
- 0
how do u post it solved
- 03-09-2009, 10:12 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Look at the top of your first post here in this thread. You can see a menu bar, on that click Thread Tools and see.
Similar Threads
-
I couldn’t figure out how to do this please help!
By afrttoh in forum New To JavaReplies: 5Last Post: 11-19-2008, 08:21 PM -
Cannot figure out min and max, without using arrays. if possible.
By loddog2002 in forum New To JavaReplies: 2Last Post: 11-08-2008, 04:58 AM -
Please Help, can't figure out what I'm doing wrong.
By tamik0 in forum New To JavaReplies: 2Last Post: 07-11-2008, 09:41 AM -
Seems so simple yet I can't figure it out!
By adamhaviland in forum New To JavaReplies: 1Last Post: 11-03-2007, 06:26 PM -
I can't figure this out
By silvia in forum New To JavaReplies: 3Last Post: 07-20-2007, 04:38 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks