Write a Java Program for the following :
1) A painter has to paint a rectangular wall. Accept the length and breadth of the wall in feet and the cost of painting a wall per sq feet and calculate the total cost of painting the wall.
2) Write a java program that computes Bowling average for a bowler who has given 1153 runs in 18 matches taking 60 wickets (Note: Bowling average is no. of runs given per wicket i.e: Runs/wicket)
Answers
Answer:
import java.util.Scanner;
public class PaintCalc
{
public static void main(String[] args)
{
int length, width, height, numberOfDoors, numberOfWindows;
Scanner console = new Scanner(System.in);
System.out.print("Enter length: ");
length = console.nextInt();
System.out.print("Enter width: ");
width = console.nextInt();
System.out.print("Enter height: ");
height = console.nextInt();
System.out.print("Enter number of doors: ");
numberOfDoors = console.nextInt();
System.out.print("Enter number of windows: ");
numberOfWindows = console.nextInt();
int totalSurfaceArea = 2 * (length * width + length
* height + width * height);
int areaOfFloor = length * width;
int areaOfDoors = 20 * numberOfDoors;
int areaOfWindows = 15 * numberOfWindows;
int totalPaintArea = totalSurfaceArea - areaOfFloor
- areaOfDoors - areaOfWindows;
int requiredPaint = totalPaintArea / 350;
System.out.println("Paint required "
+ requiredPaint + " gallons.");