Софтуерно Инженерство
Loading...
+ Нов въпрос
mihal.andonov avatar mihal.andonov 1 Точки

07 Pet shop

import java.util.Scanner;

public class PetShop {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int dogs = Integer.parseInt(scan.nextLine());
        int animals = Integer.parseInt(scan.nextLine());
        double dogfoodprice = 2.50;
        int otherfoodprice = 4;

        double allfoodcost = (dogs * dogfoodprice) + (animals * otherfoodprice);

        System.out.printf("%.2f lv", allfoodcost);

    }
}

 

това ми е кода и не мога да разбера в judg-a защо ми гърми

пробвах го по няколко варианта и все гърми

Тагове:
0
Java Fundamentals
mark79 avatar mark79 347 Точки

Здравей,

в изхода след lv трябва да има символ точка.

        System.out.printf("%.2f lv.", allfoodcost);

Поздрави :)

0
radoslav.venchev avatar radoslav.venchev 2 Точки
import java.util.Scanner;

public class PetShop {
    public static void main(String[] args) {

        //Getting the number of dogs and the rest animals.
        Scanner scanner = new Scanner(System.in);
        String dogs = scanner.nextLine();
        String animals = scanner.nextLine();

        //Converting the input data to double values and performing the calculations.
        double d_gs = Double.parseDouble(dogs) * 2.50;
        double a_ns = Double.parseDouble(animals) * 4;

        //Displaying the result
        System.out.printf("%.2f", (d_gs + a_ns));
        System.out.print(" lv.");

    }
}
0