08. Yard Greening
Здравейте!
Имам проблем със задачата и системата ми дава 70/100. Не мога да разбера къде ми е грешката.
import java.util.Scanner;
public class YardGreening {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double squareMeters = Integer.parseInt(scanner.nextLine());
double priceForLandscaping = squareMeters * 7.61;
double priceForLandscapingDiscount = (0.18 * priceForLandscaping);
double totalPrice = (priceForLandscaping - priceForLandscapingDiscount);
System.out.printf("The final price is: %.2f lv.%n", totalPrice);
System.out.printf("The discount is: %.2f lv.", priceForLandscapingDiscount);
}
}
Благодаря!
Понякога най-елементарното, не може да се забележи.
Моля, трябва си много внимание върху детайлите.
import java.util.Scanner; public class Yard { public static void main(String[] args) { //Getting the input data Scanner scanner = new Scanner(System.in); String square_meters = scanner.nextLine(); //Conversion from String to double value. double sqm = Double.parseDouble(square_meters); //Calculation of the overall price without discount double sum = (sqm * 7.61); //Calculation of the discount. double dsc = 0.18 * sum; //Getting the discount and calculating the final price with it. double fpr = (sum - dsc); //Output the result to the console System.out.print("The final price is: "); System.out.printf("%.2f", fpr); System.out.print(" lv."); System.out.print(""); System.out.println(""); System.out.print("The discount is: "); System.out.printf("%.2f", dsc); System.out.print(" lv."); System.out.print(""); } }