ソースを参照

now the message shows up

Whitney Martinez 6 年 前
コミット
dd55cf53d2
共有4 個のファイルを変更した133 個の追加81 個の削除を含む
  1. 124
    74
      Calc.java
  2. 2
    1
      Console.java
  3. 1
    0
      MainApplication.java
  4. 6
    6
      package.bluej

+ 124
- 74
Calc.java ファイルの表示

@@ -30,22 +30,20 @@ public  class Calc {
30 30
         boolean on = true;
31 31
         int num1 =0;
32 32
         int num2 =0;
33
-        
34 33
 
35 34
         
36
-       
37 35
 
38
-      
39 36
         /* System.out.println("Enter Number1");
40 37
         calcValue1 = scan.nextDouble();
41 38
         System.out.println("Enter Number2");
42 39
         calcValue2 = scan.nextDouble();
43 40
         System.out.println("Enter Number1");*/
41
+        /*
44 42
         System.out.println("Enter Number1 ");
45 43
         num1= scan.nextInt();
46 44
         System.out.println("Enter Number2 ");
47 45
         num2 = scan.nextInt();
48
-        
46
+         *//*
49 47
 
50 48
         System.out.println("Please enter the number of what you want to do");
51 49
         System.out.println("1. Add ");
@@ -55,108 +53,160 @@ public  class Calc {
55 53
         System.out.println("5. Modulus ");
56 54
         System.out.println("6. Square Root");
57 55
         System.out.println("7. Average");
56
+         */
58 57
 
59 58
         // String abc = keyboard.System.in();
60 59
         //try{
61 60
 
62 61
         //...
63 62
 
64
-     
65
-         
66
-           
67
-            while (scan.hasNextInt()){
68
-                
69
-             try{
63
+        System.out.print("Let's crunch some numbers");
64
+        while (on){
65
+            
66
+            System.out.println("Please enter the number of what you want to do");
67
+            System.out.println("1. Add ");
68
+            System.out.println("2. Substract");
69
+            System.out.println("3. Multiply ");
70
+            System.out.println("4. Division");
71
+            System.out.println("5. Modulus ");
72
+            System.out.println("6. Square Root");
73
+            System.out.println("7. Average");
74
+            System.out.println("8. to quit");
75
+            scan.hasNextInt();
70 76
             options = scan.nextInt();
71
-            switch (options){
72
-                case 1:  //Sum
73
-                System.out.print('\u000C');
74
-                answer = Math_methods.add(num1,num2);
75
-                System.out.println(answer);
76
-               
77 77
 
78
-                break;
78
+            try{
79
+                //System.out.println("Enter Number1 ");
79 80
 
80
-                case 2:   //difference:
81
-                 System.out.print('\u000C');
82
-                answer = Math_methods.minus(num1,num2);
83
-                System.out.println(answer);
81
+                //System.out.println("Enter Number2 "_);                                                                        
82
+                //options = scan.nextInt();
83
+                switch (options){
84 84
 
85
-                break;
85
+                    case 1:  //Sum
86
+                    //System.out.print('\u000C');
86 87
 
87
-                case 3:  // multiply:
88
-                 System.out.print('\u000C');
89
-                answer =  Math_methods.mult(num1,num2);
90
-                System.out.println(answer);
88
+                    System.out.println("Enter Number1 ");
89
+                    num1= scan.nextInt();
91 90
 
92
-                break;
91
+                    System.out.println("Enter Number2 ");
92
+                    num2 = scan.nextInt();
93 93
 
94
-                case  4:   //divide:
95
-                 System.out.print('\u000C');
96
-                answer =  Math_methods.div(num1,num2);
97
-                System.out.println(answer);
94
+                    answer = Math_methods.add(num1,num2);
95
+                    System.out.println(answer);
98 96
 
99
-                break;
97
+                    break;
98
+                    case 2:   //difference:
99
+                    //System.out.print('\u000C');
100
+                    System.out.println("Enter Number1 ");
101
+                    num1= scan.nextInt();
100 102
 
101
-                case 5:  //modulus: 
102
-                 System.out.print('\u000C');
103
-                answer = Math_methods.mod(num1,num2);
104
-                System.out.println(answer);
103
+                    System.out.println("Enter Number2 ");
104
+                    num2 = scan.nextInt();
105
+                    answer = Math_methods.minus(num1,num2);
106
+                    System.out.println(answer);
105 107
 
106
-                break;
108
+                    break;
107 109
 
108
-                case 6: //squareRoot:
109
-                 System.out.print('\u000C');
110
-                answer = Math_methods.squ(num1);
111
-                System.out.println(answer); 
110
+                    case 3:  // multiply:
111
+                    //System.out.print('\u000C');
112
+                    System.out.println("Enter Number1 ");
113
+                    num1= scan.nextInt();
112 114
 
113
-                break;
114
-                case 7: //Average:
115
-                 System.out.print('\u000C');
116
-                answer = Math_methods.ave(num1,num2);
117
-                System.out.println(answer); 
115
+                    System.out.println("Enter Number2 ");
116
+                    num2 = scan.nextInt();
117
+                    answer =  Math_methods.mult(num1,num2);
118
+                    System.out.println(answer);
119
+
120
+                    break;
121
+
122
+                    case  4:   //divide:
123
+                    //System.out.print('\u000C');
124
+                    System.out.println("Enter Number1 ");
125
+                    num1= scan.nextInt();
126
+
127
+                    System.out.println("Enter Number2 ");
128
+                    num2 = scan.nextInt();
129
+                    answer =  Math_methods.div(num1,num2);
130
+                    System.out.println(answer);
131
+
132
+                    break;
133
+
134
+                    case 5:  //modulus: 
135
+                    //System.out.print('\u000C');
136
+                    System.out.println("Enter Number1 ");
137
+                    num1= scan.nextInt();
138
+
139
+                    System.out.println("Enter Number2 ");
140
+                    num2 = scan.nextInt();
141
+                    answer = Math_methods.mod(num1,num2);
142
+                    System.out.println(answer);
143
+
144
+                    break;
145
+
146
+                    case 6: //squareRoot:
147
+                    //System.out.print('\u000C');
148
+                    System.out.println("Enter Number1 ");
149
+                    num1= scan.nextInt();
150
+
151
+                    System.out.println("Enter Number2 ");
152
+                    num2 = scan.nextInt();
153
+                    answer = Math_methods.squ(num1);
154
+                    System.out.println(answer); 
155
+
156
+                    break;
157
+                    case 7: //Average:
158
+                    //System.out.print('\u000C');
159
+                    System.out.println("Enter Number1 ");
160
+                    num1= scan.nextInt();
161
+
162
+                    System.out.println("Enter Number2 ");
163
+                    num2 = scan.nextInt();
164
+                    answer = Math_methods.ave(num1,num2);
165
+                    System.out.println(answer); 
166
+
167
+                    break;
168
+                    
169
+                    case 8:
170
+                    
171
+                    System.exit(0);
172
+                    break;
173
+
174
+                    default:
175
+                    System.out.println("Hello");
176
+                    System.out.print('\u000C');
118 177
 
119
-                break;
120
-                
121
-                default:
122
-                System.out.println("Hello");
123 178
                 }
179
+                
180
+
124 181
             }
125 182
             catch(NumberFormatException e){
126
-            //catch(Exception e){
183
+                //catch(Exception e){
127 184
                 System.out.printf("Wrong number or not enough numbers");
128
-                 
129
-                if(scan.equals("exit")){
130
-                    System.exit(0);
131
-                    System.out.println("Bye Falicia");
132
-                }else {
133
-            }
134
-                
185
+
186
+
135 187
             }
136
-           /* while(options == 0){
137
-                break;
188
+            /* while(options == 0){
189
+            break;
138 190
             }*/
139 191
         }
140 192
     }
141
-    }
193
+}
142 194
 
143
-    
144 195
 
145
-    /*catch(IOException e){
146
-    System.out.println(error);
147
-    abc.displayErrorMessage("Please Enter 2 digit");
148
-    }
149
-    /*
150
-    public void addNum2(int Number1, int Number2){
196
+/*catch(IOException e){
197
+System.out.println(error);
198
+abc.displayErrorMessage("Please Enter 2 digit");
199
+}
200
+/*
201
+public void addNum2(int Number1, int Number2){
151 202
 
152
-    calcValue1 = Number1 + Number2;
203
+calcValue1 = Number1 + Number2;
153 204
 
154
-    }
155
-
156
-    public int getCalcValue(){
205
+}
157 206
 
158
-    return calculationValue;
159
-     */
207
+public int getCalcValue(){
160 208
 
209
+return calculationValue;
210
+ */
161 211
 
162 212
    

+ 2
- 1
Console.java ファイルの表示

@@ -5,8 +5,9 @@ import java.util.Scanner;
5 5
 /**
6 6
  * Created by leon on 2/9/18.
7 7
  */
8
-public class Console {
9 8
 
9
+public class Console {
10
+    
10 11
     public static void print(String output, Object... args) {
11 12
         System.out.printf(output, args);
12 13
     }

+ 1
- 0
MainApplication.java ファイルの表示

@@ -4,6 +4,7 @@
4 4
  * Created by leon on 2/9/18.
5 5
  */
6 6
 public class MainApplication {
7
+    
7 8
    /* public static void main(String[] args) {
8 9
         Console.println("Welcome to my calculator!");
9 10
         String s = Console.getStringInput("Enter a string");

+ 6
- 6
package.bluej ファイルの表示

@@ -4,16 +4,16 @@ dependency1.to=Math_methods
4 4
 dependency1.type=UsesDependency
5 5
 editor.fx.0.height=709
6 6
 editor.fx.0.width=800
7
-editor.fx.0.x=369
8
-editor.fx.0.y=23
7
+editor.fx.0.x=6
8
+editor.fx.0.y=30
9 9
 objectbench.height=198
10 10
 objectbench.width=352
11 11
 package.divider.horizontal=0.5993322203672788
12 12
 package.divider.vertical=0.685099846390169
13 13
 package.editor.height=439
14 14
 package.editor.width=493
15
-package.editor.x=84
16
-package.editor.y=23
15
+package.editor.x=446
16
+package.editor.y=91
17 17
 package.frame.height=709
18 18
 package.frame.width=619
19 19
 package.numDependencies=1
@@ -52,5 +52,5 @@ target4.name=MainApplication
52 52
 target4.showInterface=false
53 53
 target4.type=ClassTarget
54 54
 target4.width=120
55
-target4.x=70
56
-target4.y=70
55
+target4.x=80
56
+target4.y=260