import java.util.Scanner;
public class House {
public static void main(String[] args) {
double width, length, area;
int HowManyhouses;
Scanner i=new Scanner(System.in);
System.out.println("Please Enter Length");
length= i.nextDouble();
System.out.println("Please Enter Width");
width= i.nextDouble();
System.out.println("How Many Houses Are There?");
HowManyhouses= input.nextInt();
area= length*width;
System.out.println(area);
}
}
I only know how to calculate the average for one house but how do i calculate the area for all of the houses and to make it identical?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another program i need help with.
Write a program that asks for a test grade from the user.
The program will then output a letter grade according to the following range of values.
A: 90+
B: 80-89
C: 70-79
D: 65-69
F: 0-64
Error: when the input was negative (this is the default case)
import java.util.Scanner;
public class 2 {
public static void main(String[] args) {
double test;
int x=0;
Scanner i =new Scanner(System.in);
System.out.println("Enter a grade");
test = i.nextDouble();
if(x>90)
System.out.println("A");
else if(x<=89 && x>=80)
System.out.println("B");
else if(x<=79 && x>=70)
System.out.println("C");
else if(x<=69 && x>=65)
System.out.println("D");
else if(x<=64 && x>=0)
System.out.println("F");
else if(x<0)
System.out.println("Error");
}
}
Something's wrong in this program and i don't know what the mistake is.
This post has been edited by qualityowns: 01 January 2009 - 04:14 PM

New Topic/Question
Reply




MultiQuote




|