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
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;
Related Q & A:
- Please help - how do I delete a profile?Best solution by Yahoo! Answers
- Could anyone please help me make a good msn name :D?Best solution by Yahoo! Answers
- Could somebody please help me come up with a really cool msn name?Best solution by Yahoo! Answers
- Can anyone please recommend a good staff agency to help me find an entry level business analyst position?Best solution by jobsearch.about.com
- Can someone please help me to make a hotmail.fr address?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.