Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. import java.util.Scanner;
  2. import cs1.Keyboard;
  3. public class foreign
  4. {
  5.    private static int choice;
  6.     private static int count;
  7.     private String country;
  8.     private double dollars, cvalue, camount;
  9.  
  10.  
  11.     public foreign()   //set everything to null
  12.     {
  13.       choice = 0;
  14.       country = "";
  15.       dollars = 0;
  16.       cvalue = 0;
  17.       camount = 0;
  18.       count = 0;
  19.     }  
  20.     public static void title()
  21.        {
  22.         System.out.println("Foreign Exchange\n");
  23.         }
  24.     public static void menu()
  25.        {
  26.         System.out.println("\nChoose your currency:\n");
  27.         System.out.println("1. US to Canada");
  28.         System.out.println("2. US to Mexico");
  29.         System.out.println("3. US to Japan");
  30.         System.out.println("4. US to Euro");
  31.         System.out.println("0. Quit\n");
  32.         }
  33.    public static int choice()
  34.        {
  35.         Scanner read = new Scanner(System.in);   
  36.       System.out.print("\nEnter your choice: ");
  37.         choice = read.nextInt();  //input choice
  38.         return choice;
  39.         }
  40.     public void amount()
  41.        {
  42.          switch (choice)  //use the choice to define the values
  43.           {
  44.           case 1:  country = "Canada";            
  45.                          cvalue = 1.0267;                
  46.                          break;
  47.           case 2:  country = "Mexico";            
  48.                          cvalue = 12.5484;
  49.                    break;
  50.           case 3:  country = "Japan";            
  51.                          cvalue = 123.78;            
  52.                          break;
  53.           default: country = "Euro";      
  54.                          cvalue = 0.7424;
  55.           }
  56.              Scanner read = new Scanner(System.in);  
  57.           System.out.print("Enter Dollar amount: ");
  58.           dollars = read.nextDouble();
  59.        }         
  60.     public void calculate ()    //calculate the conversion
  61.         {
  62.            camount = dollars * cvalue;
  63.             count++;
  64.          }       
  65.     public void vertical ()    //create vertical output
  66.         {
  67.            System.out.println("Country = " + country);
  68.             System.out.println("Rate = " + cvalue);
  69.             System.out.println("Dollars = " + dollars);
  70.             System.out.println("Value = " + camount);
  71.          }       
  72.      public String toString()
  73.         {
  74.            String s;          //create horizontal output
  75.             s = country + " " + cvalue + " " + dollars + " " + camount + " ";
  76.            
  77.             return s;
  78.          }
  79.      public static int count()
  80.         {
  81.            return count;
  82.          }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement