Help on Lisp programming question.

Please help! A question about programming?

  • I'm trying to create a Java program for finding the area of a rectangle width 5.7 by length 4.8 This is what I put into Ready To Program: public class Area /* *Name *This program is to determine *the area of a 5.7 by 4.8 rectangle */ { public static void main(String[] args) { //variable declaration int principal, rate; //variable initialization principal = 5.7; rate = 4.8; //calculations interest = principal * rate; //output System.out.println("Area Program"); System.out.println("The area is" + interest); } } It keeps giving me errors. I'm really new to all this computer science programming, so I basically have no idea what I'm doing. Please help! I need this program to work so I can multiply 5.7 by 4.8.

  • Answer:

    I do not really know Java, but from experience from other programming languages I think you just forgot to declare the interest variable. You must declare it too: //variable declaration int principal, rate, interest;

єm.lєαh.... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

class Area /* *Name *This program is to determine *the area of a 5.7 by 4.8 rectangle */ { public static void main(String args[]) { //variable declaration double principal, rate, interest; //variable initialization principal = 5.7; rate = 4.8; //calculations interest = principal * rate; //output System.out.println("Area Program"); System.out.println("The area is" + interest); } }

You never declared/initialized interest. int principal, rate; should be: int principal, rate, interest;

ints are whole numbers 5,10,576893 doubles/floats and such have decimals 5.2 53.73 5.7 , 4.8 are doubles which is your problem :)

You are declaring your variables (principal, rate, & interest) as "int" (integer), but you are trying to use them to contain floating point numbers, like 5.7 and 4.8. Change your declarations from "int" to "double".

int principal, rate -- do not declare your variables as int. Declare them double. double principal, rate, interest;

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.