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(); }}

5th Nov 2016, 3:54 PM
Avish Kathpal
Avish Kathpal - avatar
6 odpowiedzi
+ 3
you are creating a void program with a return. Please check it
5th Nov 2016, 4:16 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 3
everything is wrong with it.
6th Nov 2016, 1:34 PM
Alireza M
Alireza M - avatar
0
void method cannot returning any values
5th Nov 2016, 4:19 PM
Maciej Góraj
Maciej Góraj - avatar
0
what if I add amount = money - x;
5th Nov 2016, 4:21 PM
Avish Kathpal
Avish Kathpal - avatar
0
what do you want actually, please write more information
5th Nov 2016, 4:24 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
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(); } }
5th Nov 2016, 7:08 PM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar