Skip to content

Commit

Permalink
Merge pull request #7 from 101zh/unit4.1
Browse files Browse the repository at this point in the history
Unit4.1
  • Loading branch information
101zh authored Oct 25, 2023
2 parents 6bfcf67 + 3669c68 commit fb93fc4
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
{
"configurations": [
{
"type": "java",
"name": "U4_L1_Activity_Three",
"request": "launch",
"mainClass": "Unit4.U4_L1_Activity_Three",
"projectName": "my-app"
},
{
"type": "java",
"name": "U4_L1_Activity_Two",
"request": "launch",
"mainClass": "Unit4.U4_L1_Activity_Two",
"projectName": "my-app"
},
{
"type": "java",
"name": "U4_L1_Activity_One",
"request": "launch",
"mainClass": "Unit4.U4_L1_Activity_One",
"projectName": "my-app"
},
{
"type": "java",
"name": "Assignment3",
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/Unit4/U4_L1_Activity_One.java
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();
}
}
24 changes: 24 additions & 0 deletions src/main/java/Unit4/U4_L1_Activity_Three.java
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();
}
}
21 changes: 21 additions & 0 deletions src/main/java/Unit4/U4_L1_Activity_Two.java
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();
}
}

0 comments on commit fb93fc4

Please sign in to comment.