Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. import java.lang.*;
  2. import java.util.*;
  3.  
  4. /*
  5. Description: This application will be used to convert a user given volume
  6. in cups to its equivalent number of teaspoons, tablespoons, ounces, pints
  7. quarts, or gallons.
  8.  
  9. This program will allow us to view what a certain volume of cups would be in
  10. tablespoons, teaspoons etc.
  11.  
  12. This program will need the number of cups from the user.
  13. Then the program will output the neccessary teaspoons, tablespoons etc.
  14.  
  15. 4 cups equals 4 * 48 = 192 teaspoons
  16. 4 cups equals 4 * 16 = 64 tablespoons
  17. 4 cups equals 4 * 8 = 32 ounces
  18. 4 cups equals 4 * 0.5 = 2 pints
  19. 4 cups equals 4 * 0.25 = 1 quart
  20. 4 cups equals 4 * 0.0625 = 0.2500 gallon
  21.  
  22. java.util and java.text will be used
  23.  
  24. The input and output will be simple text based interactions using
  25. system.out.Println and scanner
  26.  
  27. Psuedocode:
  28. Output a welcome message
  29. Output a message that describes what the program will do
  30. Output a message requesting the number cups the user wishes to
  31. convert
  32.  
  33. read the input value and store it
  34.  
  35. calculate the teaspoons, tablespoons etc and store it.
  36.  
  37. output a message that displays this values so the user can see
  38. it
  39. */
  40.  
  41. class cupsconversion
  42. {
  43.  
  44. public static void main(String[] args)
  45. {
  46. System.out.println("Welcome to Shahrukhs Cup Conversion Program");
  47. System.out.println();
  48. System.out.println("This application will be used to convert a user given volume");
  49. System.out.println("in cups to its equivalent number of teaspoons, tablespoons, ounces, pints");
  50. System.out.println("quarts, or gallons");
  51. System.out.println("n n");
  52. System.out.println("Please type in a +ve real value for the number of cups you want converted");
  53. System.out.print(" Number of cups = ");
  54.  
  55. Scanner input = new Scanner(System.in);
  56.  
  57. float cups; // We are storing the input the user puts in float.
  58.  
  59. cups = input.nextFloat();
  60.  
  61. float teaspoons = cups * 48;
  62.  
  63. float tablespoons = cups * 16;
  64.  
  65. float ounces = cups * 8;
  66.  
  67. float pints = cups * 0*5;
  68.  
  69. float quarts = cups * 0.25;
  70.  
  71. float gallons = cups * 0.0625;
  72.  
  73. System.out.println(" Given " + cups + " cups, the volume in teaspoons are " + teaspoons);
  74. System.out.println(" Given " + cups + " cups, the volume in tablespoons are " + tablespoons);
  75. System.out.println(" Given " + cups + " cups, the volume in ounces are " + ounces);
  76. System.out.println(" Given " + cups + " cups, the volume in pints are " + pints);
  77. System.out.println(" Given " + cups + " cups, the volume in quarts are " + quarts);
  78. System.out.println(" Given " + cups + " cups, the volume in gallons are " + gallons);
  79.  
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement