I need to create a program on the command line that is essentially a flash card
ID: 3713824 • Letter: I
Question
I need to create a program on the command line that is essentially a flash card game. I will write the program based off of a text file in Ubuntu, and I am having trouble understanding how to differentiate between words and definitions from the text file in my actual program. for example, the text file will have many statements like "Java: a programming language" and I need the questions in my program to read "What is java? A) a programming language B) whatever C) whatever D) whatever. I am also having trouble figuring out how to get the program to know which option corresponds to the right answer and grade the player accordingly.
Explanation / Answer
I had a good suggestion for you to create this game.
NOTE:please read it and understand carefully it is an optimised and simple solution for your problem...
First you need to write all the statements in a file as follows
//file.txt---In this file you have to write the statements has to be asked by the program
java:a programming language
html:web designing language
css:stylesheets
...
...
..
you have to write all the statements with keyword:answer format..
now we write a java program as
//Algorthim to given game
flashcardgame(){
read the file and save as two dimensional array
as first dimension keyword(word before colon)
second dimension(statement after colon).
run in a loop so that we get all the keywords and statements respectively
now we have all the questions and respective answers in array
now ask question to user as
what is+(some random keyword from array(first_dimensioni))?
A.some random statement from the array(second dimension).
B.some random statement from the array(second dimension).
C.answer from the array with same index as question number(second dimension).
D.some random statement from the array(second dimension).
like this you can generate random questions and random options
take input from user and check if array index matches to both dimensions
and give marks correspondingly.
}
hope this helps...
Thankyou....:)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.