Thursday, March 31, 2016

Exercise 1.5

1.5 (Compute expressions) Write a program that displays the result of

9.5 * 4.5 - 2.5 * 3
___________________

45.5 - 3.5

My solution:


public class Ex_one_pt_five {
/*
Author: Brooks Robinson
Problem: (Compute expressions) Write a program that displays the result of

9.5 * 4.5 - 2.5 * 3
___________________

   45.5 - 3.5
*/

public static void main(String[] args) {

System.out.println("The result of \n");
System.out.println("9.5 * 4.5 - 2.5 * 3");
System.out.println("___________________");
System.out.println("    45.5 - 3.5\n");
System.out.println("is: \n");
System.out.println(((9.5*4.5)-(2.5*3))/(45.5-3.5));

} //end of main

} //end of class

No comments:

Post a Comment