커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
요리 레시피 메모장 만들기 숙제 관련
Java 문법 종합반 v0
1주차
북마크
이*진
댓글
2
추천
0
조회수
43
조회수
43
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


요리 제목 -> 별점 ->요리 과정 순서로 입력을 받는데

분명 요리 과정 10가지를 모두 입력을 시도 하면 9개만 입력이 받아지고

1번째는 공백으로 출력 되고 2번 ~ 10번까지 출력됩니다.



스파르타 즉문즉답

보시다시피 1번 부터 출력이 되야 하지만 한줄이 입력이 다 되지도 않았는데 결과가 나왔습니다.


결과 예시

스파르타 즉문즉답



작성한 코드 및 에러 메세지

별도의 오류 메세지는 없습니다.

오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.

Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.

Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!



import java.util.Scanner;

public class First_project {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String cookName = sc.nextLine();
        float score = sc.nextFloat();
        String recipe1 = sc.nextLine();
        String recipe2 = sc.nextLine();
        String recipe3 = sc.nextLine();
        String recipe4 = sc.nextLine();
        String recipe5 = sc.nextLine();
        String recipe6 = sc.nextLine();
        String recipe7 = sc.nextLine();
        String recipe8 = sc.nextLine();
        String recipe9 = sc.nextLine();
        String recipe10 = sc.nextLine();

        int scoreNumber = (int)score; // 별점 int 형 변환
        double percentage = scoreNumber * 100 / 5; // 퍼센트 계산

        // 결과 출력
        System.out.println("[" + cookName + "]");
        System.out.println("별점 : " + scoreNumber + " (" + percentage + "%)");
        System.out.println("1. " + recipe1);
        System.out.println("2. " + recipe2);
        System.out.println("3. " + recipe3);
        System.out.println("4. " + recipe4);
        System.out.println("5. " + recipe5);
        System.out.println("6. " + recipe6);
        System.out.println("7. " + recipe7);
        System.out.println("8. " + recipe8);
        System.out.println("9. " + recipe9);
        System.out.println("10. " + recipe10);
    }
}

취소
 공유
취소
댓글 0
댓글 알림
나의얼굴