Click here to Skip to main content
11,577,965 members (66,265 online)
   

Java

 
GeneralRe: Read JNDI from c# Pin
Richard MacCutchan11-Apr-13 0:38
mvpRichard MacCutchan11-Apr-13 0:38 
GeneralRe: Read JNDI from c# Pin
Member 111849411-Apr-13 0:42
memberMember 111849411-Apr-13 0:42 
SuggestionRe: Read JNDI from c# Pin
Prasad Khandekar2-May-13 19:49
professionalPrasad Khandekar2-May-13 19:49 
QuestionJava Program to accept input from user and then display output . Pin
Aman kumar routh4-Apr-13 3:35
memberAman kumar routh4-Apr-13 3:35 
I need to make a java program which accepts input from user in form of item Code, quantity and rate and then display the total amount as well as discount .
the condition for getting discount is like
if the amount is greater than 5000 than discount is 10% of amount. i want to display amount and discount amount calculated ...my code works nice till it calculates amount but when moving to next step for calculating discount it shows error.

plzzz hep me out ...is there any error in my code??
am new to Core java
thank you...


import java.io.*;
class AMOUNT
{
public static void main(String args[])
{
Double discount= 0.0 ;
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader br= new BufferedReader(istream);
System.out.println("Welcome to My Java Program");
try
{
System.out.println("enter the item code:");
String code=br.readLine();

System.out.println("enter your quantity:");
String quantity=br.readLine();

System.out.println("enter the rate:");
String rate=br.readLine();

int qty=Integer.parseInt(quantity);
int Rate=Integer.parseInt(rate);



int amnt= qty*Rate;
System.out.println("your amountis"+amnt);

if(amnt > 5000)
{
discount=Double.parseDouble(br.readLine());
discount= 0.1 * amnt;
System.out.println("your discount is"+discount);
}
else
{

System.out.println("you dont have discount");
}
}
catch (Exception e)
{
System.out.println("error");

}
}
}
Aman Kumar Routh

AnswerRe: Java Program to accept input from user and then display output . Pin
emadrefai4-Apr-13 6:20
memberemadrefai4-Apr-13 6:20 
GeneralRe: Java Program to accept input from user and then display output . Pin
Aman kumar routh4-Apr-13 6:29
memberAman kumar routh4-Apr-13 6:29 
AnswerRe: Java Program to accept input from user and then display output . Pin
Richard MacCutchan4-Apr-13 6:29
mvpRichard MacCutchan4-Apr-13 6:29 
QuestionJAVA Pin
Member 995424830-Mar-13 8:01
memberMember 995424830-Mar-13 8:01 
AnswerRe: JAVA Pin
Richard MacCutchan30-Mar-13 13:19
mvpRichard MacCutchan30-Mar-13 13:19 
AnswerRe: JAVA Pin
Shubhashish_Mandal1-Apr-13 2:43
memberShubhashish_Mandal1-Apr-13 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 4 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid