Soujanya Buragapu 6 anos atrás
pai
commit
7ae97a9e9e
2 arquivos alterados com 34 adições e 33 exclusões
  1. 15
    14
      .idea/workspace.xml
  2. 19
    19
      src/main/java/Question1.java

+ 15
- 14
.idea/workspace.xml Ver arquivo

@@ -2,6 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="ff0f55eb-552a-45f4-8a74-866e22f63e9a" name="Default" comment="">
5
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
5 6
       <change beforePath="$PROJECT_DIR$/src/main/java/Question1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Question1.java" afterDir="false" />
6 7
     </list>
7 8
     <ignored path="$PROJECT_DIR$/out/" />
@@ -22,12 +23,12 @@
22 23
       </usages-collector>
23 24
       <usages-collector id="statistics.file.extensions.edit">
24 25
         <counts>
25
-          <entry key="java" value="718" />
26
+          <entry key="java" value="1048" />
26 27
         </counts>
27 28
       </usages-collector>
28 29
       <usages-collector id="statistics.file.types.edit">
29 30
         <counts>
30
-          <entry key="JAVA" value="718" />
31
+          <entry key="JAVA" value="1048" />
31 32
         </counts>
32 33
       </usages-collector>
33 34
       <usages-collector id="statistics.spring.boot.run.usages" />
@@ -60,8 +61,8 @@
60 61
       <file pinned="false" current-in-tab="true">
61 62
         <entry file="file://$PROJECT_DIR$/src/main/java/Question1.java">
62 63
           <provider selected="true" editor-type-id="text-editor">
63
-            <state relative-caret-position="395">
64
-              <caret line="87" column="92" selection-start-line="87" selection-start-column="92" selection-end-line="87" selection-end-column="92" />
64
+            <state relative-caret-position="247">
65
+              <caret line="67" column="30" lean-forward="true" selection-start-line="67" selection-start-column="30" selection-end-line="67" selection-end-column="30" />
65 66
               <folding>
66 67
                 <element signature="e#1408#1409#0" expanded="true" />
67 68
                 <element signature="e#1456#1457#0" expanded="true" />
@@ -73,8 +74,8 @@
73 74
       <file pinned="false" current-in-tab="false">
74 75
         <entry file="file://$PROJECT_DIR$/src/test/java/Question1Test.java">
75 76
           <provider selected="true" editor-type-id="text-editor">
76
-            <state relative-caret-position="225">
77
-              <caret line="15" column="18" selection-start-line="15" selection-start-column="17" selection-end-line="15" selection-end-column="35" />
77
+            <state relative-caret-position="285">
78
+              <caret line="19" lean-forward="true" selection-start-line="19" selection-end-line="19" />
78 79
             </state>
79 80
           </provider>
80 81
         </entry>
@@ -177,7 +178,7 @@
177 178
   <component name="PropertiesComponent">
178 179
     <property name="WebServerToolWindowFactoryState" value="false" />
179 180
     <property name="aspect.path.notification.shown" value="true" />
180
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1541037127180" />
181
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1541073267663" />
181 182
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
182 183
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
183 184
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
@@ -322,7 +323,7 @@
322 323
       <option name="presentableId" value="Default" />
323 324
       <updated>1541012263419</updated>
324 325
       <workItem from="1541012264832" duration="5000000" />
325
-      <workItem from="1541023510544" duration="5715000" />
326
+      <workItem from="1541023510544" duration="6833000" />
326 327
     </task>
327 328
     <servers />
328 329
   </component>
@@ -359,7 +360,7 @@
359 360
     </history-entry>
360 361
   </component>
361 362
   <component name="TimeTrackingManager">
362
-    <option name="totallyTimeSpent" value="10715000" />
363
+    <option name="totallyTimeSpent" value="11833000" />
363 364
   </component>
364 365
   <component name="ToolWindowManager">
365 366
     <frame x="0" y="0" width="1280" height="800" extended-state="6" />
@@ -375,7 +376,7 @@
375 376
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
376 377
       <window_info anchor="bottom" id="Message" order="0" />
377 378
       <window_info anchor="bottom" id="Find" order="1" />
378
-      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3410959" />
379
+      <window_info anchor="bottom" id="Run" order="2" weight="0.3410959" />
379 380
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
380 381
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
381 382
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -425,15 +426,15 @@
425 426
     </entry>
426 427
     <entry file="file://$PROJECT_DIR$/src/test/java/Question1Test.java">
427 428
       <provider selected="true" editor-type-id="text-editor">
428
-        <state relative-caret-position="225">
429
-          <caret line="15" column="18" selection-start-line="15" selection-start-column="17" selection-end-line="15" selection-end-column="35" />
429
+        <state relative-caret-position="285">
430
+          <caret line="19" lean-forward="true" selection-start-line="19" selection-end-line="19" />
430 431
         </state>
431 432
       </provider>
432 433
     </entry>
433 434
     <entry file="file://$PROJECT_DIR$/src/main/java/Question1.java">
434 435
       <provider selected="true" editor-type-id="text-editor">
435
-        <state relative-caret-position="395">
436
-          <caret line="87" column="92" selection-start-line="87" selection-start-column="92" selection-end-line="87" selection-end-column="92" />
436
+        <state relative-caret-position="247">
437
+          <caret line="67" column="30" lean-forward="true" selection-start-line="67" selection-start-column="30" selection-end-line="67" selection-end-column="30" />
437 438
           <folding>
438 439
             <element signature="e#1408#1409#0" expanded="true" />
439 440
             <element signature="e#1456#1457#0" expanded="true" />

+ 19
- 19
src/main/java/Question1.java Ver arquivo

@@ -3,34 +3,34 @@ public class Question1 {
3 3
     //returns random integers between 7(s+1) and 1
4 4
     public static void doSomething0()
5 5
     {
6
-        int s = 6;
6
+        int s = 6; // s is variable of integer type and value initializes as 6
7 7
 
8
-        int r = (int) (Math.random() * s) + 1;
8
+        int r = (int) (Math.random() * s) + 1; // r = random integers between 7(s+1) and 1
9 9
 
10
-        System.out.println(r);
10
+        System.out.println(r); // print the r value
11 11
     }
12 12
 
13 13
     public static void doSomething1(int n)
14 14
     {
15 15
         int foo = 1;
16 16
 
17
-        while (foo <= n / 2) {
18
-            foo *= 2;
17
+        while (foo <= n / 2) { // first lets take n value as 5 , 1 <=5/2
18
+            foo *= 2; // now foo is 4
19 19
         }
20 20
 
21
-        while (foo > 0) {
21
+        while (foo > 0) { //4>0 (condition true)
22 22
 
23
-            if (n < foo) {
23
+            if (n < foo) { //5<4 (condition false)
24 24
                 System.out.print(0);
25 25
             } else {
26
-                System.out.print(1);
27
-                n -= foo;
26
+                System.out.print(1); // prints 1
27
+                n -= foo; // n=1
28 28
             }
29 29
 
30
-            foo /= 2;
30
+            foo /= 2; // foo value 0 and 1
31 31
         }
32 32
 
33
-        System.out.println();
33
+        System.out.println(); // prints 0 and 1
34 34
     }
35 35
     // 1)n=4,i=0,p=1 , repeated while loop upto i=4 and printed the values of i and p
36 36
     // 2)n=12,i=0,p=1, repeated while loop upto i=12 and printed the values of i and p
@@ -64,16 +64,16 @@ public class Question1 {
64 64
         System.out.println(t);
65 65
     }
66 66
 
67
-    public static void doSomething4(double x) {
68
-        x = x % (2 * Math.PI);
67
+    public static void doSomething4(double x) { ////let us take x =5.2
68
+        x = x % (2 * Math.PI); // x=5.2%(2*3.145)=0.32672563
69 69
 
70 70
         double term = 1.0;
71 71
         double sum  = 0.0;
72 72
 
73
-        for (int i = 1; term != 0.0; i++) {
74
-            term *= (x / i);
75
-            if (i % 4 == 1) sum += term;
76
-            if (i % 4 == 3) sum -= term;
73
+        for (int i = 1; term != 0.0; i++) { //i is 1 and term is not equal to 0  and  increment the value of i
74
+            term *= (x / i); //term=0.32672563;0.16335
75
+            if (i % 4 == 1) sum += term; // i=0.04
76
+            if (i % 4 == 3) sum -= term; // i=0.04
77 77
         }
78 78
         System.out.printf("%.4f\t%.8f\n", x, sum);
79 79
     }
@@ -92,8 +92,8 @@ public class Question1 {
92 92
         while (d < n) {
93 93
             int value = getInt(n);
94 94
             k++;
95
-            if (!a[value]) {
96
-                d++;
95
+            if (!a[value]) { // if a[value] is false
96
+                d++; // increment the value of d
97 97
                 a[value] = true;
98 98
             }
99 99
         }