هذا تقريبا اجتهادي في حل الفقرة الاولي من سوال الاخت مستجدة
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication2;
import java.util.Scanner;
/
*
* @author ahmed ali
*/
public class JavaApplication2 {
/
* @param args the command line arguments
*/
public static void main(String[] args) {
final int COVERAGE = 350; //paint covers 350 sq ft/gal
int length, width,height; //declare integers length, width, and height;
double totalSqFt; //declare double totalSqFt;
double paintNeeded; //declare double paintNeeded;
Scanner sc = new Scanner(System.in);
System.out.println( "Please enter the length of the room: " );
length = sc.nextInt();
System.out.println( "Please enter the width of the room: " );
width = sc.nextInt();
System.out.println( "Please enter the height of the room: " );
height = sc.nextInt();
totalSqFt=(2*length*height)+ (2*width*height);//Compute the total square feet to be painted
paintNeeded= totalSqFt / COVERAGE;//Compute the amount of paint needed
System.out.printf("\nThe length of the room is %d",length);
System.out.printf("\nnThe width of the room is %d",width);
System.out.printf("\nThe height of the room is %d",height);
System.out.printf("\nThe number of gallons of paint needed is %f",paintNeeded," gallons. \n");
paintNeeded= Math.ceil(paintNeeded);
System.out.printf(" so you have to purchase %f",paintNeeded," gallons. \n");
}
}