Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 KB | None | 0 0
  1. #53
  2.  
  3. //Author RobertGelin
  4. //This program makes two random numbers and prints the smaller of the two
  5. import java.util.Random;
  6. public class numGen53 {
  7.  public static void main(String[] args) {
  8.  
  9.         Random random = new Random();
  10. //Generate random numbers
  11.         int firstNUM = random.nextInt(10)+1;
  12.         int secondNUM = random.nextInt(10+1);
  13.  
  14. //Set the if-else statements.      
  15.         if (firstNUM < secondNUM)
  16.             System.out.println("The smaller number is" + firstNUM);
  17.        
  18.        
  19.      else if (secondNUM < firstNUM);
  20.             System.out.println("The smaller number is" + secondNUM);
  21.  
  22. }
  23. }
  24.  
  25.  
  26. #54
  27. //Author -Robert Gelin
  28.  
  29.  
  30. // This program will take a double as an input and compute the square of that number.
  31. // It will then output said number.
  32.  
  33.     import javax.swing.JOptionPane;  //Import your packages.
  34.     import java.util.Scanner;
  35.    
  36.     public class cubeNUM {
  37.     public static void main(String [] args){
  38.  
  39.     Scanner scan = new Scanner  (System.in);
  40.  //Ask the user for an input
  41.  System.out.println("Please enter a double");
  42.     double firstNUM = scan.nextDouble();
  43.  //Calculate your input value
  44.  
  45.     firstNUM = Math.pow(firstNUM, 3);
  46.  //Display your output value.
  47.     System.out.println(" Your end result is " + firstNUM);
  48. }
  49. }
  50.  
  51.  #55
  52. /*This program will read a filename from a dialog box. And tell you whether or not it is a valid filename.
  53.  */
  54. /*
  55. @author Robert Gelin
  56.  */
  57. import javax.swing.JOptionPane;
  58. public class fileReader {
  59.     public static void main(String[] args) {
  60.     //Declare variables
  61.        String fileName;
  62.        String fileExtension;
  63.        int dotLocation;
  64.        fileName = JOptionPane.showInputDialog (null, "Enter a filename");
  65.        dotLocation = fileName.indexOf('.');
  66.        //set up if-else statments to cover possilbe invalid inputs .
  67.        if (dotLocation == -1 )
  68.                JOptionPane.showMessageDialog (null, "No input was found: Derp");
  69.         else
  70.         { dotLocation ++;
  71.        fileExtension = fileName.substring(dotLocation);
  72.        JOptionPane.showMessageDialog(null,"Your filetype is:    "    + fileExtension);
  73. }
  74. }
  75. }
  76. #57
  77. //This program will count a given amount of input (in terms of coins) and output the result in terms of dollars.
  78.  
  79. //@author Robert Gelin
  80. //Import Objects.
  81. import javax.swing.JOptionPane;
  82. public class cashCount {
  83.     public static void main(String[] args) {
  84.    double firstBoxValue = Double.parseDouble(JOptionPane.showInputDialog(null, "Please input an amount of change in quarters."));
  85.    //First test run was done here.
  86.  
  87.    double secondBoxValue = Double.parseDouble(JOptionPane.showInputDialog(null, "Please input a second amount of change in nickels."));
  88.    double thirdBoxValue =Double.parseDouble(JOptionPane.showInputDialog(null, "Please input a third amount of change in dimes"));
  89.    double totalValue = firstBoxValue*.25+ secondBoxValue*.05+ thirdBoxValue*.1;
  90.    JOptionPane.showMessageDialog(null," your total amount of money is:  "+ totalValue);
  91. }
  92. }
  93.  
  94.  
  95.  
  96.    
  97.  
  98.  
  99.  #63
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement