0
Some chargee and discount
29 odpowiedzi
+ 1
https://code.sololearn.com/cG8ZOzrEWj5W/?ref=app
+ 1
Assign value to amt Or use scanner to input value..
Ex:use this line,
int amt = 20000;
edit:
Techno Team use this above line, instead of
int amt;
+ 1
May u do it correct in my code
+ 1
I'm unable to get it
+ 1
Do help
+ 1
No output is coming
+ 1
import java.util.Scanner;
public class Discount
{
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);
int amt = in.nextInt();
double dis;
if(amt<=2000)
dis=0.025;
else if(amt>=2001&&amt<=4000)
dis=0.04*amt;
else if(amt>=4001&&amt<=7000)
dis=0.07*amt;
else
dis=0.10*amt;
System.out.println("Your purchase is "+amt+" so your discount is "+dis+" Thanks for shopping");
}
}
//Techno Team you forgot to add static to main method:
+ 1
Help here too
+ 1
Line no:5 remove '{' and add it in place of ';' in line no:3
Changes needed, Remaining all are same as your last program. take input to amt;
+ 1
May u do the same u did above
+ 1
That's 7 min ago
+ 1
I said what changes you need. You should try now...!
Happy learning. ..
0
public static void main(String[] args)
{
int amt; double dis;
Scanner sc = new Scanner(System.in);
amt = sc.nextInt();
if(amt<=2000)
// …
0
Like i have to write scanner class too
0
If you want to take input, then use scanner class. Otherwise manually do like
int amt = 20000;
(before, Read last 4mins ago post, first)
0
Oky
0
I'm doing and if i can't do give me some more hints
0
Notify with updated code..
0
Check this out