teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

1

2019/12/17 03:09

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,51 +1,1 @@
1
- ```> ここに言語を入力
2
- ```
3
- ### 前提・実現したいこと変数
4
- int num にシステムから入力値が与えられます。
5
- 下記のメソッドを作成してください。
6
- メソッドを作成したら、mainにてそのメソッドを呼出し、下記の条件分岐を実装してください。
1
+ -------------------------------------------
7
- なお、メソッドの呼び出し時の実引数は、入力値である変数 int num を設定してください。
8
- calculationメソッド
9
- 0から数値型の引数までの数値の和を戻り値としてください。
10
- mainメソッドでの条件分岐
11
- 戻り値が200以上の場合、「200以上です」と出力。
12
- 戻り値が100以上200未満の場合、「100以上200未満です」と出力。
13
- 戻り値が100未満の場合、「100未満です」と出力。
14
- 戻り値が0以下の場合、「数値が不正です」と出力。
15
- ```
16
- エラーメッセージ
17
- Main.java:17: error: cannot find symbol
18
- if(total>200){
19
- ^
20
- symbol: variable total
21
- location: class Main
22
- Main.java:20: error: cannot find symbol
23
- else if(total>100){
24
- ^
25
- symbol: variable total
26
- location: class Main
27
- 2 errors
28
- ```
29
- ### 該当のソースコード
30
- import java.util.Scanner;
31
- public class Main {
32
- static int calculation(int num){
33
- int total= 0;
34
- for(int i=0; i<=num; i++){
35
- total += i;
36
- }
37
- return total;
38
- }
39
- public static void main(String[] args) {
40
- Scanner scan = new Scanner(System.in);
41
- String text = scan.next();
42
- int num = Integer.parseInt(text);
43
- if(total>200){
44
- System.out.println("200以上です");
45
- }
46
- else if(total>100){
47
- System.out.println("100以上200未満です");
48
-
49
- }else{
50
- System.out.println("100未満です");
51
- }さい。

2

1

2019/12/17 03:09

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,16 +1,51 @@
1
- ```>
1
+ ```> ここに言語を入力
2
-
3
-
4
- }
5
- }
6
-
7
- ソースコード
8
2
  ```
9
-
10
- ### したこと
3
+ ### 前提・実現したこと変数
11
-
12
- ここ問題に対して試したことを記載してください
4
+ int num システムから入力値が与えられます
13
-
14
- ### 補足情報(FW/ツールのバージョンなど)
15
-
16
- ここにより詳細な情報をしてください。
5
+ のメソッドを作成してください。
6
+ メソッドを作成したら、mainにてそのメソッドを呼出し、下記の条件分岐を実装してください。
7
+ なお、メソッドの呼び出し時の実引数は、入力値である変数 int num を設定してください。
8
+ calculationメソッド
9
+ 0から数値型の引数までの数値の和を戻り値としてください。
10
+ mainメソッドでの条件分岐
11
+ 戻り値が200以上の場合、「200以上です」と出力。
12
+ 戻り値が100以上200未満の場合、「100以上200未満です」と出力。
13
+ 戻り値が100未満の場合、「100未満です」と出力。
14
+ 戻り値が0以下の場合、「数値が不正です」と出力。
15
+ ```
16
+ エラーメッセージ
17
+ Main.java:17: error: cannot find symbol
18
+ if(total>200){
19
+ ^
20
+ symbol: variable total
21
+ location: class Main
22
+ Main.java:20: error: cannot find symbol
23
+ else if(total>100){
24
+ ^
25
+ symbol: variable total
26
+ location: class Main
27
+ 2 errors
28
+ ```
29
+ ### 該当のソースコード
30
+ import java.util.Scanner;
31
+ public class Main {
32
+ static int calculation(int num){
33
+ int total= 0;
34
+ for(int i=0; i<=num; i++){
35
+ total += i;
36
+ }
37
+ return total;
38
+ }
39
+ public static void main(String[] args) {
40
+ Scanner scan = new Scanner(System.in);
41
+ String text = scan.next();
42
+ int num = Integer.parseInt(text);
43
+ if(total>200){
44
+ System.out.println("200以上です");
45
+ }
46
+ else if(total>100){
47
+ System.out.println("100以上200未満です");
48
+
49
+ }else{
50
+ System.out.println("100未満です");
51
+ }さい。

1

1

2019/11/13 06:18

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,69 +1,5 @@
1
- ```> ここに言語を入力
1
+ ```>
2
2
 
3
- ```
4
- ### 前提・実現したいこと変数
5
- int num にシステムから入力値が与えられます。
6
-
7
- 下記のメソッドを作成してください。
8
-
9
- メソッドを作成したら、mainにてそのメソッドを呼出し、下記の条件分岐を実装してください。
10
-
11
- なお、メソッドの呼び出し時の実引数は、入力値である変数 int num を設定してください。
12
-
13
- calculationメソッド
14
- 0から数値型の引数までの数値の和を戻り値としてください。
15
-
16
- mainメソッドでの条件分岐
17
- 戻り値が200以上の場合、「200以上です」と出力。
18
-
19
- 戻り値が100以上200未満の場合、「100以上200未満です」と出力。
20
-
21
- 戻り値が100未満の場合、「100未満です」と出力。
22
-
23
- 戻り値が0以下の場合、「数値が不正です」と出力。
24
-
25
- ```
26
- エラーメッセージ
27
- Main.java:17: error: cannot find symbol
28
- if(total>200){
29
- ^
30
- symbol: variable total
31
- location: class Main
32
- Main.java:20: error: cannot find symbol
33
- else if(total>100){
34
- ^
35
- symbol: variable total
36
- location: class Main
37
- 2 errors
38
- ```
39
-
40
- ### 該当のソースコード
41
- import java.util.Scanner;
42
- public class Main {
43
-
44
- static int calculation(int num){
45
- int total= 0;
46
- for(int i=0; i<=num; i++){
47
- total += i;
48
- }
49
-
50
- return total;
51
- }
52
- public static void main(String[] args) {
53
- Scanner scan = new Scanner(System.in);
54
- String text = scan.next();
55
- int num = Integer.parseInt(text);
56
-
57
- if(total>200){
58
- System.out.println("200以上です");
59
- }
60
- else if(total>100){
61
- System.out.println("100以上200未満です");
62
-
63
- }else{
64
- System.out.println("100未満です");
65
- }
66
-
67
3
 
68
4
  }
69
5
  }