0
what's the mistake in it
import java.util.Scanner; class big{ public static void A(){ Scanner input = new Scanner (System.in); float amount,total,x,dis,money; System.out.println("Enter the amount"); money= Integer.parseInt(input.nextLine()); System.out.println("Enter the discount percentage"); dis= Integer.parseInt(input.nextLine()); total = dis/100; x = total*money; return money-x; } public static void main(){ big.A(); }}
6 Answers
+ 3
you are creating a void program with a return. Please check it
+ 3
everything is wrong with it.
0
void method cannot returning any values
0
what if I add amount = money - x;
0
what do you want actually, please write more information
0
/* The was alot of errors in you code, the errows was indeed void class dont return to anything and you have indicated it to retun. But i have fix the errors;
*/
Fixed errod code:
import java.util.Scanner;
public class Test{
static void A(){
Scanner input = new Scanner (System.in);
float amount; float total; float x; float dis; float money;
System.out.println("Enter the amount");
money = Integer.parseInt(input.nextLine());
System.out.println("Enter the discount percentage");
dis = Integer.parseInt(input.nextLine());
total = dis/100; x = total*money;
}
public static void main(String[] args){
A();
}
}
Error code(your code unfixed):
class big{
public static void A(){
Scanner input = new Scanner (System.in);
float amount,total,x,dis,money;
System.out.println("Enter the amount");
money= Integer.parseInt(input.nextLine());
System.out.println("Enter the discount percentage");
dis= Integer.parseInt(input.nextLine());
total = dis/100; x = total*money;
return money-x;
} public static void main(){
big.A();
}
}