# Need some help with this program

Page 1 of 1

## 1 Replies - 589 Views - Last Post: 01 January 2009 - 04:18 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=78971&amp;s=10a429a359977787a07bf9afa58941d9&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 qualityowns

Reputation: 0
• Posts: 7
• Joined: 23-November 08

# Need some help with this program

Posted 01 January 2009 - 03:29 PM

Write a program that asks the user for the length and width of a house, and how many houses there are. The program then calculates and prints the total square footage of all of the houses(each house is identical)

```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);
length= i.nextDouble();
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);

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

Is This A Good Question/Topic? 0

## Replies To: Need some help with this program

### #2 nick2price

• D.I.C Lover

Reputation: 563
• Posts: 2,826
• Joined: 23-November 07

## Re: Need some help with this program

Posted 01 January 2009 - 04:18 PM

so you work out the area for 1 house
area=length*width;

so now make a new vairable called total area and multiply the number of houses by the area of each house
double totalArea = howManyHouses * area;

System.out.println(totalArea);

P.s, if a moderator reads this, the code button is now prompting me a scripted window, which then links me to the hyperlink insert. Think the code button is messed up.