0
Thanks A.s. for Correcting my mistake
can you give me your number a.s
11 Respostas
+ 1
s
thanks you so much A.s.
+ 1
Tanay Rastogi can u tell me char pc i didn't understood our words
+ 1
in question there is saying use pc as in char
+ 1
Tanay Rastogi can u tell little bit more what exactly u expecting
+ 1
//Ques of the give program
write a program to input product code (pc) in character, quantity of the product purchased (qty) and rate of 1 piece of product (rate ). calculate the total purchase amount and print it along with the gift to be presented on the following basis :
Amount of purchase (Rs. ) gift to be present
200 and above but less than 700 a key chain
700 and above but less than 1200 a carry bag
1200 and above an electronic cal
culator
//thank you A.s I was giving only one input that's why my program is not working.. thanks for correcting me to give 3 inputs to compiler. thaks A.s
+ 1
+ 1
can you give me your number
0
import java.util.*;
class l
{
public static void main (String[]args)
{
Scanner sc=new Scanner (System.in);
System.out.println ("Enter product code");
char pc =sc.next().charAt(0);
System.out.println ("Enter quantity of the product purchase");
int qty =sc.nextInt();
System.out.println ("Enter rate of one piece of product");
int rate=sc.nextInt();
int a=qty*rate;
System.out.println("Amount="+a);
if(a>=200 && a<700)
{
System.out.println ("A key chain");
}
else if (a>=700 && a<1200)
{
System.out.println("A carry bag");
}
else if(a>=1200)
{
System.out.println("An electric calculator");
}
}
}// check where is error in this program
0
Tanay Rastogi
Your code is incomplete. Make code in Code Playground and share the link with your question.
0
Tanay Rastogi your code is working if u trying on sololearn plateform then u need to give all input's at same time i tried its working without any error your program requires three inputs
0
Tanay Rastogi why u take char PC? As there is no use of it :/