2017-11-09 2 views
-3

여기 내 현재 코드입니다 다른 답변을 얻을 수 있습니다 그 기간의 마지막 것. 예를 들어, 나는 그 때 내가 얻을 것 내 초기 재고 값으로 550을하면 내 기간으로 십일일 넣고 다음코드를 수정하는 것은

내가 대신 수행 할 작업을
Day Share Points 
1 550 
2 600 
3 575 
4 625 
5 600 
6 650 
7 625 
8 675 
9 650 
10 700 
11 675 

같은 경우 (그래서 최종 답변을 변경입니다

The share points on the final day would be: 675 
다음
+3

입니다 : 값은 다음과 같을한다) 입력 어떻게 해결하려고 했습니까? – pvg

+1

그래서 출력 문자열에 텍스트를 추가하려고합니다. 해당 문자열을 출력하고 거기에 텍스트를 입력하는 코드 줄로 가려고 했습니까? – David

답변

1
private static void outPutTablePrinter(int numberOfDays,int sharePoints){ 
//  System.out.println("Day " + " Share Points"); 
//  System.out.println(1 + " " + sharePoints); 
     for (int i = 2; i <= numberOfDays; i++) { 
      if (numberOfDays % 2 == 0) 
       if (i <= numberOfDays/2) { 
        sharePoints = sharePoints + 50; 
//     System.out.println(i + " " + sharePoints); 
       } else { 
        sharePoints = sharePoints - 25; 
//     System.out.println(i + " " + sharePoints); 
       } else { 
       if (i <= numberOfDays/2 + 1) { 
        sharePoints = sharePoints + 50; 
//     System.out.println(i + " " + sharePoints); 
       } else { 
        sharePoints = sharePoints - 25; 
//     System.out.println(i + " " + sharePoints); 
        // above nested if else statements essentially calculate 
        // and concatenate the variables to obtain an answer that is then printed 
        // and repeated until the number of days is reached (starting from day two) 
       } 
      } 
     } 
     System.out.println("The share points on the final day would be: "+sharePoints); 
}  

당신이 만남을했습니다 문제가 무엇인지 출력

Number of days in the period: 11 
Share points on the first day: 550 
The share points on the final day would be: 675 
관련 문제