Difficulty: Easy
Time to solve: <5 min
Video this is covered in: 6



import java.util.Scanner;
public class Jtutorial1 {
    public static void main(String args[]){
    Scanner input = new Scanner(System.in);
        
     int x=5;
     
     if (x = 10){
         System.out.println("I love you heaps!");
     }
     else{
         System.out.println("I love waffles");
     }
    
    }//end main
}//end class

Error information:Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – incompatible types
required: boolean
found: int
at Jtutorial1.main(Jtutorial1.java:8)

Difficulty: Easy
Time to solve: <5 min
Video this is covered in: 6



import java.util.Scanner;
public class Jtutorial1 {
    public static void main(String args[]){
    Scanner input = new Scanner(System.in);
        
    System.out.println("How much does Employee 1 make? ");
    double emp1 = input.nextDouble();
    
    System.out.println("How much does Employee 2 make? ");
    double emp2 = input.nextDouble();
    
    System.out.println("How much does Employee 3 make? ");
    double emp3 = input.nextDouble();    
    
    if (emp1 > emp2){
    if (emp1 > emp3){
        System.out.println("Employee 1 makes more than the other 2 employees");
    }
    else{
        System.out.println("Employee 3 makes more than Employee 1.");
    }
    else{
        System.out.println("Employee 2 makes more than employee 1");
    }
    
    
    }//end main
}//end class

Input:
500
400
300

Program Output:
How much does Employee 1 make?
How much does Employee 2 make?
How much does Employee 3 make?
Employee 1 makes more than the other 2 employees
Error information:Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – ‘else’ without ‘if’
at Jtutorial1.main(Jtutorial1.java:22)

In his challenge I ask that you do the following things:

Create a program that will:

  1. Use loops to complete the tasks below
  2. Print out a list of all the numbers that meet the following criteria, one item per line.
  3. Are either: Prime, or Multiples of 3, or 8, but not both 3 and 8, less than 2500

Concepts used: Variables, loops, arithmatic functions, breaks

You should be able to do this by: Lesson 13 — 16 will help.

My solution: –Will come back and add one eventually

Please note that my solutions are not checked thoroughly, and should only be used for reference. They are often non-optimal solutions that could be improved upon (by you!). I keep these intentionally rough for just that reason.