Ques1 Program takes two double numbers amount(A) and interest®and an integer number years(n) and prints out all input and amount earned after 5 years .the amount earned in a year is calculated by An+1 = An*R .If an entered number is less than 0 display "invalid input".
This is not working properly
[code]
import java.util.*;
public class amount
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
//get a number and assign it to variable
System.out.println("Pls enter Principal : ");
int A1 = keyboard.nextInt();
System.out.println("Pls enter Rate of interest charged : ");
int R1 = keyboard.nextInt();
int N = 5;
if (A1>0)
{
int A1 = A1+1* int R1;
{System.out.println("Amount = "+ A1);
}
Else if (A1<0)
{
{System.out.println("Invalid Input");
}
}
}
}
Java Problem Program takes two double numbers amount(A) and interest(R)and an inte
Page 1 of 1
4 Replies - 487 Views - Last Post: 01 September 2009 - 06:05 PM
Replies To: Java Problem
#2
Re: Java Problem
Posted 01 September 2009 - 01:38 AM
handa, on 1 Sep, 2009 - 05:03 PM, said:
Ques1 Program takes two double numbers amount(A) and interest®and an integer number years(n) and prints out all input and amount earned after 5 years .the amount earned in a year is calculated by An+1 = An*R .If an entered number is less than 0 display "invalid input".
This is not working properly
This is not working properly
import java.util.*;
public class amount
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
//get a number and assign it to variable
System.out.println("Pls enter Principal : ");
int A1 = keyboard.nextInt();
System.out.println("Pls enter Rate of interest charged : ");
int R1 = keyboard.nextInt();
int N = 5;
if (A1>0)
{
int A1 = A1+1* int R1;
{System.out.println("Amount = "+ A1);
}
Else if (A1<0)
{
{System.out.println("Invalid Input");
}
}
}
}
First thing first no need to redeclare A1 or R1 as int it just creates errors.
Also if you want double numbers, A1 and R1 should be declared as double.
Else is actually else. Java is a case sensitive language.
import java.util.*;
public class amount
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
//get a number and assign it to variable
System.out.println("Pls enter Principal : ");
double A1 = keyboard.nextDouble();
System.out.println("Pls enter Rate of interest charged : ");
double R1 = keyboard.nextDouble();
double N = 5;
if (A1>0)
{
A1 = A1 + 1 * R1;
System.out.println("Amount = "+ A1);
}
else if (A1<0)
{
System.out.println("Invalid Input");
}
}
}
This post has been edited by Travis1012: 01 September 2009 - 01:53 AM
#3
Re: Java Problem
Posted 01 September 2009 - 08:29 AM
It would help if you posted the errors you are getting. I dunno if Travis solved all your problems or not, but please be a little more descriptive of your errors in the future.
#4
Re: Java Problem
Posted 01 September 2009 - 06:03 PM
NeoTifa, on 1 Sep, 2009 - 07:29 AM, said:
It would help if you posted the errors you are getting. I dunno if Travis solved all your problems or not, but please be a little more descriptive of your errors in the future.
And please, Handa, respect rule #5 of this forum
"Java Help" is kind of a useless topic title in a forum dedicated to help people with problem in Java
P.S. why have I always to be the one writing this ?
#5
Re: Java Problem
Posted 01 September 2009 - 06:05 PM
pbl, on 1 Sep, 2009 - 07:03 PM, said:
"Java Help" is kind of a useless topic title in a forum dedicated to help people with problem in Java
P.S. why have I always to be the one writing this ?
P.S. why have I always to be the one writing this ?
Well, first of all, that's wrong. In this particular thread...it's Java Problem.
And, I dunno why you're the only one that writes those.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote









|