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

Summer Outfit - задача - проблем в Judge

Здравейте, аз по същия начин я написах, но в джъджа ми дава 80/100 ? Каде е грешката ми не разбирам.

Първо я направих със Switch, същатата работа, после го замених с иф елсове и пак 80/100...

 

package com.company;

import java.util.Scanner;

public class SummerOutFit {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int degree = Integer.parseInt(scan.nextLine());
        String fit = scan.nextLine().toLowerCase();
        String outfit = "";
        String shoes = "";


        if ("morning".equals(fit)) {
            if (degree >= 10 && degree <= 18) {
                outfit = "Sweatshirt";
                shoes = "Sneakers";
                System.out.printf("It's %d degrees, get your %s and %s.", degree, outfit, shoes);
            } else if (degree > 18 && degree <= 24) {
                outfit = "Shirt";
                shoes = "Moccasins";
                System.out.printf("It's %d degrees, get your %s and %s.", degree, outfit, shoes);
            } else if (degree > 25) {
                outfit = "T-Shirt";
                shoes = "Sandals";
                System.out.printf("It's %d degrees, get your %s and %s.", degree, outfit, shoes);
            }
        } else if ("afternoon".equals(fit)) {
            if (degree >= 10 && degree <= 18) {
                outfit = "Shirt";
                shoes = "Moccasins";
                System.out.printf("It's %d degrees, get your %s and %s.", degree, outfit, shoes);
            } else if (degree > 18 && degree <= 24) {
                outfit = "T-Shirt";
                shoes = "Sandals";
                System.out.printf("It's %d degrees, get your %s and %s.", degree, outfit, shoes);
            } else if (degree > 25) {
                outfit = "Swim Suit";
                shoes = "Barefoot";
                System.out.printf("It's %d degrees, get your %s and %s.", degree, outfit, shoes);
            }
        } else {
            outfit = "Shirt";
            shoes = "Moccasins";
            System.out.printf("It's %d degrees, get your %s and %s.", degree, outfit, shoes);
        }
    }
}

 

Тагове:
0
Programming Basics with Java 26/03/2020 13:28:04
Stoikokolev avatar Stoikokolev 16 Точки

else if - трябва да са ти ">24", а творите са ">25"

по този начин проверката с 25 градуса не я обхващаш

1
KlimentHristov avatar KlimentHristov 55 Точки

Благодаря ти колега, наистина това е проблема!

0