Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7. /**
  8. *
  9. * @author IT12FC1
  10. */
  11. import java.util.*;
  12. import java.text.*;
  13. public class PreLab1 {
  14. public static void main (String[] args){
  15. double add, sub, mult, div, ave;
  16. DecimalFormat decFor4 = new DecimalFormat(".####");
  17. DecimalFormat decFor = new DecimalFormat(".0000");
  18. Scanner input = new Scanner (System.in);
  19.  
  20. System.out.print("Enter 1st Number: ");
  21. double w = input.nextDouble();
  22. System.out.print("Enter 2nd Number: ");
  23. double x = input.nextDouble();
  24. System.out.print("Enter 3rd Number: ");
  25. double y = input.nextDouble();
  26. System.out.print("Enter 4th Number: ");
  27. double z = input.nextDouble();
  28.  
  29. add = w+x+y+z;
  30. sub = w-x-y-z;
  31. mult = w*x*y*z;
  32. div = w/x/y/z;
  33. ave = w+x+y+z/4;
  34. System.out.println("Sum: "+decFor.format(add));
  35. System.out.println("Difference: "+decFor.format(sub));
  36. System.out.println("Product: "+decFor.format(mult));
  37. System.out.println("Quotient: "+decFor4.format(div));
  38. System.out.println("Average: "+decFor4.format(ave));
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement