Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions learning-java-project/java/javatest/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin"
}
18 changes: 18 additions & 0 deletions learning-java-project/java/javatest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

## Folder Structure

The workspace contains two folders by default, where:

- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the `bin` folder by default.

> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management

The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file added learning-java-project/java/javatest/bin/App.class
Binary file not shown.
Binary file added learning-java-project/java/javatest/src/App.class
Binary file not shown.
5 changes: 5 additions & 0 deletions learning-java-project/java/javatest/src/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
Binary file added src/Main.class
Binary file not shown.
37 changes: 26 additions & 11 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
import java.util.Scanner;

public class Main {

public static void main(String args[]) {
String question = "";
String choiceOne = "";
String choiceTwo = "";
String choiceThree = "";

String correctAnswer = choiceTwo;

String question = "Say my name!";
String choiceOne = "Willie Wonka";
String choiceTwo = "Woodrow Wilson";
String choiceThree = "Walter White";
String correctAnswer = choiceThree;
// Write a print statement asking the question
System.out.println(question);
// Write a print statement giving the answer choices

System.out.println(choiceOne);
System.out.println(choiceTwo);
System.out.println(choiceThree);

Scanner input = new Scanner(System.in);
// Have the user input an answer
// Retrieve the user's input

String userAnswer = input.next();
input.close();

// If the user's input matches the correctAnswer...
// then the user is correct and we want to print out a congrats message to the user.


if(userAnswer.equals(correctAnswer)) {
System.out.println("Congrats! You have choosen the correct answer!!!");
};

// If the user's input does not match the correctAnswer...
// then the user is incorrect and we want to print out a message saying that the user is incorrect as well as what the correct choice was.


if(!userAnswer.equals(correctAnswer)) {
System.out.println("You failed!!!");
}
}

}