Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author IT12FC1
- */
- import java.util.*;
- import java.text.*;
- public class PreLab1 {
- public static void main (String[] args){
- double add, sub, mult, div, ave;
- DecimalFormat decFor4 = new DecimalFormat(".####");
- DecimalFormat decFor = new DecimalFormat(".0000");
- Scanner input = new Scanner (System.in);
- System.out.print("Enter 1st Number: ");
- double w = input.nextDouble();
- System.out.print("Enter 2nd Number: ");
- double x = input.nextDouble();
- System.out.print("Enter 3rd Number: ");
- double y = input.nextDouble();
- System.out.print("Enter 4th Number: ");
- double z = input.nextDouble();
- add = w+x+y+z;
- sub = w-x-y-z;
- mult = w*x*y*z;
- div = w/x/y/z;
- ave = w+x+y+z/4;
- System.out.println("Sum: "+decFor.format(add));
- System.out.println("Difference: "+decFor.format(sub));
- System.out.println("Product: "+decFor.format(mult));
- System.out.println("Quotient: "+decFor4.format(div));
- System.out.println("Average: "+decFor4.format(ave));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement