filmov
tv
Learning Java - Part 7 - Program to create multiple choice questions

Показать описание
Sample Program: Multiple choice
It's time to practice your control flow skills with this sample code.
Be sure to use the tools you've learned about so far, including
1. if statements,
2. while loops,
3. variables, and
4. input-output.
For this sample program, you will implement a single multiple-choice question in Java. You will come up with a question as well as three possible answer choices.
One of these choices should be the correct answer. Using your knowledge of control flow and input and output, you will ask the user the question as well as provide the possible answer choices. The user will respond with one of these choices. If the user is correct, we will print out a congratulations message. If the user is incorrect, we will print out that the user is incorrect, as well as what the correct answer choice is.
So now lets walk through the code step by step in this video.
We could also add more multiple-choice questions. With what we know so far adding additional questions would require us to add a significant amount of code.
If you want to create a more efficient quiz with several multiple-choice questions you'll need to learn about data structures which is a more advanced topic that's out of the video of this course. In working on this sample program you may have run into some tough errors, and that's okay. In the next video we'll look at how we can debug our programs by finding some common coding errors and fixing them
It's time to practice your control flow skills with this sample code.
Be sure to use the tools you've learned about so far, including
1. if statements,
2. while loops,
3. variables, and
4. input-output.
For this sample program, you will implement a single multiple-choice question in Java. You will come up with a question as well as three possible answer choices.
One of these choices should be the correct answer. Using your knowledge of control flow and input and output, you will ask the user the question as well as provide the possible answer choices. The user will respond with one of these choices. If the user is correct, we will print out a congratulations message. If the user is incorrect, we will print out that the user is incorrect, as well as what the correct answer choice is.
So now lets walk through the code step by step in this video.
We could also add more multiple-choice questions. With what we know so far adding additional questions would require us to add a significant amount of code.
If you want to create a more efficient quiz with several multiple-choice questions you'll need to learn about data structures which is a more advanced topic that's out of the video of this course. In working on this sample program you may have run into some tough errors, and that's okay. In the next video we'll look at how we can debug our programs by finding some common coding errors and fixing them