Advertisement
cgorrillaha

Unit2Prelab 1

Sep 21st, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. class Main {
  5.   public static void main(String[] args) {
  6.     System.out.println("This is a long string that is the " + "concatenation of two shorter strings.");
  7.  
  8.     System.out.println("The first computer was invented about " + 55 + " years ago.");
  9.  
  10.     System.out.println("8 plus 5 is " + 8 + 5);
  11.  
  12.     System.out.println("8 plus 5 is " + (8 + 5));
  13.  
  14.     System.out.println(8 + 5 + " equals 8 plus 5.");
  15.     System.out.println("Ten robins plus 13 canaries is" + (10 + 13) + "birds.");
  16.  
  17.     final int NUM_1 = 55;
  18.     int num2 = 23;
  19.     num2 = 45;
  20.  
  21.     int myNumber = 45;
  22.     myNumber = 12 + 12;
  23.  
  24.     // prelabs============================================
  25.     int val1, val2, val3;
  26.     double average;
  27.     Scanner scan = new Scanner(System.in);
  28.  
  29.     // get three values from user
  30.     System.out.println("Please enter three integers and " + "I will compute their average");
  31.     val1 = scan.nextInt();
  32.     val2 = scan.nextInt();
  33.     val3 = scan.nextInt();
  34.     // compute the average
  35.     average=(val1+va2+val3)/3;
  36.     // print the average
  37.     System.out.println("Average of three numbers: "+average);
  38.   }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement