// Write your name on each answer sheet.   Good Luck!

// Fold your paper in half. Trace on left. Output on right. Don't let the blank lines make you crazy.

// 25% if you leave a question blank. 0% if you write garbage. Do what the computer would do!!

// Do not emulate the poor style. This is an exam!

 

// SampleExam.java                     CISC 1115

// Write your name on each answer sheet.   Good Luck!

// Fold your paper in half. Trace on left. Output on right. Don't let the blank lines make you crazy.

// 25% if you leave a question blank. 0% if you write garbage. Do what the computer would do!!

// Do not emulate the poor style. This is an exam!

 

// SampleExam.java                     CISC 1115

 

import java.util.Scanner;

import java.io.File;

 

public class SampleExam {

 

  public static void main(String[] args) throws Exception {

   

    System.out.println("SampleExam  CISC 1115");

    //System.out.println("COMMENT");

    q1();//20 pts;

    q2();//20 pts.

    q3();//20 pts.

  }

 

  //  The user will enter 20 and 10.5

  public static void q1() {

    final double TAX = 25.00;

    double hours, rate, gross, net;

    Scanner sc = new Scanner(System.in);

   

    System.out.println("\n1)");

    System.out.println("Enter hours worked and rate of pay: ");

    hours = sc.nextDouble();

    rate = sc.nextDouble();

   

    gross = hours * rate;

    net = gross - TAX;

   

    System.out.printf("The gross pay is: $%.2f\n", gross);

    System.out.printf("The net pay is: $%.2f\n", net);

  }  

 

  //..... 

  public static void q2()  {

    int n=10;

    double x = 1.5;

 

    System.out.println("\n2)");

    n = (int) (x + 1.8);

    System.out.printf("%d %.2f %10.3f\n", n, Math.ceil(x), x);

  }

 

  // Assume the file contains:  4     2     5     3 

  public static void q3() throws Exception {

    int w, x, y, z;

    Scanner sc = new Scanner(new File("Sample.txt"));

 

    System.out.println("\n3)");

    w = sc.nextInt();

    x = sc.nextInt();                  

    y = sc.nextInt();

    z = sc.nextInt();

                             if (w > x) {

                               x = x + y;

                               y = w + z;

                             } else if (x > y) {

                               w = x + z;

                               y = y + w;

                             }

     System.out.printf("%d  %d  %d  %d\n", w, x, y, z);

                            

                             if (w < x && y > z)

                               w = 1;

                             else if (w < z)

                               x = 1;

                             else

                               y = 1;   

                              

     System.out.printf("%d  %d  %d  %d\n", w, x, y, z);                                                 

  }                              

                             

}

/* 4)(40 pts.) Write a complete Java program in good style to do the following:
a) prompt for and read the measured length of the shorter sides of a right triangle.
b) call a method to calculate and print the area of the triangle (half the the product of sides).
c) call a method to calculate and display the length of the hypotenuse (c*c=a*a +b*b).
Use a 3,4,5 triangle as one of the sets of test data yo make your calculations easy. Only the code will be graded, but you should trace to make sure your program works before you submit it. */

 

/* OUTPUT

SampleExam  CISC 1115

 

1)

Enter hours worked and rate of pay: 

20

10.5

The gross pay is: $210.00

The net pay is: $185.00

 

2)

3 2.00      1.500

 

3)

4  7  7  3

1  7  7  3

 */