This program isn't giving the name as output.. Can someone pls hlp me out?
import java.util.* ;
class Discount
{
String name ;
double price ,amt ,dis ;
Discount(String name1, double price1) {
name = name1 ;
dis = 0.0;
amt = 0.0;
price = price1 ; }
void accept () {
Scanner ch = new Scanner(System.in) ;
System.out.println("Enter the name of the customer :") ;
String name = ch.nextLine();
System.out.println("Enter the price of the laptop " ) ;
price = ch.nextDouble(); }
void calculate (){
if(price<=25000){
dis = 5/100*price;}
else if(price>=25001&&price<=50000){
dis = 7.5/100*price;}
else if(price>=50001&&price<=100000){
dis = 10/100*price;}
else {
dis = 15/100*price;}
amt = price - dis ;}
void display (){
System.out.println("The name of customer is :" + name);
System.out.println("The discount is :" + dis );
System.out.println("The amount to be paid is : " + amt ); }
public static void main (String args []){
Discount obj = new Discount(" ", 0.0);
obj.accept ();
obj.calculate();
obj.display(); }}
Dhrub Dubey
Level 1
Output not showing, rest program is working correctly
Under discussion
Comments
- Popular
- New
- Old
You must be signed in to leave a comment
This page doesn't have any comments yet