0

please help me out i want discount rate upto decimal figure (upto 6 digit)

public class DiscountPrice{ public static void main(String[] args) { int offer; int disc; double rate; System.out.println("Enter the current offer price:-"); Scanner offerPrice = new Scanner (System.in); offer = offerPrice.nextInt(); System.out.println("Enter the discount price "); Scanner discPrice = new Scanner (System.in); disc = discPrice.nextInt(); rate = 100 - (disc * 100 / offer); System.out.println("the discount percentage is " + (rate)); } } //the discount percentage rate is not coming in exact decimal figures

7th Apr 2020, 7:41 PM
joyti negi
joyti negi - avatar
2 Antworten
0
in rate calculation, offer, disc both and 100 all integers so result also you get only Integer. No decimal point value. To result a double value, use atleast one double in calculation like 100.0 Or take one of offer, disc as double values.. Why are taking two Scanner objects..? One is enough for a program.. You can use only one..
7th Apr 2020, 8:01 PM
Jayakrishna 🇮🇳
0
thanks..... it works.... :)
7th Apr 2020, 8:10 PM
joyti negi
joyti negi - avatar