dtwins
02-03-2012, 06:46 PM
ey guys, need help with java not compiling, here is the code and errors.
[CODE]
/** PROGRAM ASSIGNMENT 1 DaltonBrandonP2.java
*
* Author: Dalton Brandon
* Class: Java, Online
* Due Date: February 8, 2012
* See if roof needs changed, calculate price per square foot
*/
import java.util.Scanner;
public class DaltonBrandonP2 {
public static void main(String[] args) {
System.out.println("Dalton Brandon, Program Assignment 2, Java, online");
//New Scanner
Scanner input = new Scanner(System.in);
while (again == 1) {
//Year house was built
System.out.print("What year was the house built?: ");
int year = input.nextint();
//Square foot of house
System.out.print("Enter square feet of house: ");
double square = input.nextdouble();
//Total price
System.out.print("Enter total price: ");
double price = input.nextdouble();
//Does roof need changing?
void ifRoofChangeNeeded(int year){
if ((2012 - year) >= 15)
System.out.print("Roof change is needed");
else
System.out.print("No roof change is needed");
}
//Calculate price per square foot
void calcPricePersqf(double square, price){
int priceSqrf = price / square;
System.out.print("Price per square foot is: " + priceSqrf);
return priceSqrf;
}
System.out.print("Work on another house? 1 for YES, 2 for NO: ");
int again = input.nextint();
}
}
}
[CODE]
ERRORS
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:32: error: illegal start of expression
void ifRoofChangeNeeded(int year){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:32: error: ';' expected
void ifRoofChangeNeeded(int year){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:32: error: ';' expected
void ifRoofChangeNeeded(int year){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:39: error: illegal start of expression
void calcPricePersqf(double square, price){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:39: error: ';' expected
void calcPricePersqf(double square, price){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:39: error: ';' expected
void calcPricePersqf(double square, price){
^
6 errors
Tool completed with exit code 1
---------------------------------------------------------------------------------------------------------
Am using TextPad, required for class
[CODE]
/** PROGRAM ASSIGNMENT 1 DaltonBrandonP2.java
*
* Author: Dalton Brandon
* Class: Java, Online
* Due Date: February 8, 2012
* See if roof needs changed, calculate price per square foot
*/
import java.util.Scanner;
public class DaltonBrandonP2 {
public static void main(String[] args) {
System.out.println("Dalton Brandon, Program Assignment 2, Java, online");
//New Scanner
Scanner input = new Scanner(System.in);
while (again == 1) {
//Year house was built
System.out.print("What year was the house built?: ");
int year = input.nextint();
//Square foot of house
System.out.print("Enter square feet of house: ");
double square = input.nextdouble();
//Total price
System.out.print("Enter total price: ");
double price = input.nextdouble();
//Does roof need changing?
void ifRoofChangeNeeded(int year){
if ((2012 - year) >= 15)
System.out.print("Roof change is needed");
else
System.out.print("No roof change is needed");
}
//Calculate price per square foot
void calcPricePersqf(double square, price){
int priceSqrf = price / square;
System.out.print("Price per square foot is: " + priceSqrf);
return priceSqrf;
}
System.out.print("Work on another house? 1 for YES, 2 for NO: ");
int again = input.nextint();
}
}
}
[CODE]
ERRORS
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:32: error: illegal start of expression
void ifRoofChangeNeeded(int year){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:32: error: ';' expected
void ifRoofChangeNeeded(int year){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:32: error: ';' expected
void ifRoofChangeNeeded(int year){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:39: error: illegal start of expression
void calcPricePersqf(double square, price){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:39: error: ';' expected
void calcPricePersqf(double square, price){
^
C:\Users\Dalton Brandon\Desktop\JAVA\Assignment 2\DaltonBrandonP2.java:39: error: ';' expected
void calcPricePersqf(double square, price){
^
6 errors
Tool completed with exit code 1
---------------------------------------------------------------------------------------------------------
Am using TextPad, required for class