generated from microsoft/vscode-remote-try-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from 101zh/unit4.1
Unit4.1
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package Unit4; | ||
|
||
import java.util.Scanner; | ||
|
||
public class U4_L1_Activity_One { | ||
public static void main(String[] args){ | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
int num=0; | ||
System.out.println("Enter any numbers (Enter 5 to stop)"); | ||
int sum=0; | ||
while (num!=5){ | ||
sum+=num; | ||
num=scanner.nextInt(); | ||
} | ||
|
||
System.out.println("Sum is "+sum); | ||
scanner.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package Unit4; | ||
|
||
import java.util.Scanner; | ||
|
||
public class U4_L1_Activity_Three { | ||
public static void main(String[] args){ | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
System.out.println("Input a word:"); | ||
String word =scanner.nextLine(); | ||
|
||
int index=0; | ||
while (index<word.length()){ | ||
|
||
if((index+1)%3!=0 && index<word.length()){ | ||
System.out.print(word.substring(index, index+1)); | ||
} | ||
|
||
index++; | ||
} | ||
|
||
scanner.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package Unit4; | ||
|
||
import java.util.Scanner; | ||
|
||
public class U4_L1_Activity_Two { | ||
public static void main(String[] args){ | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
int largest=0; | ||
int num=0; | ||
while (num!=-1){ | ||
num = scanner.nextInt(); | ||
if(largest<num){ | ||
largest=num; | ||
} | ||
} | ||
|
||
System.out.println("The largest score is "+largest); | ||
scanner.close(); | ||
} | ||
} |