Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm reposting this question because the last time it got answered, the person didn't do any gui for it. I'm including the code that does

I'm reposting this question because the last time it got answered, the person didn't do any gui for it. I'm including the code that does the inputing of the files below.

Create a GUI flashcard program using Java Swing components that read a data file input; The goal of this project is to create a simple GUI flashcard program. At launch the program should ask the user to select a file containing questions and answers to use. The data should be read into one data structure that holds a series of Flashcard objects. These Flashcard objects should have at least two attributes (a question and a related answer) in addition to any other attributes and or methods needed. The flashcard data structure should be randomized. Each time the program is run the order of the flashcards should be unique. Do some research the easy solution to this is only one line of code. The GUI should consist of a single JLabel and JButton. On starting, the JLabel should display a welcome message and the JButton should display Start. After starting the first question should been displayed and the button should display Click for Answer. Upon the next click the label should display the answer and the button should display Next Question. After the last question has been answered the program should display a dialog box asking the user if they want to go through the questions again. The main button should be disabled. The data file should be plain text but can be in whatever format you choose to use. The text file should be created with a text editor. There is no need to have the

import javax.swing.*; import java.awt.*; import java.util.*; import java.io.*;

public class GuiFlashCard{

JFrame jf; JLabel la; JButton jb;

String Question[]; String Answer[];

public static void main(String ss[]){

GuiFlashCard qa = new GuiFlashCard (); qa.readFile(); }

void readFile(){

int mc = 0; int qc = 0; int ac = 0;

try{

Scanner sc = new Scanner( new File ( "QA.txt" ));

while( sc.hasNext ()) {

Question[qc] = new String( "" );

Answer[ac] = new String( "" );

String data = sc.nextLine();

if( mc % 2 == 0 ) { Question[ qc ] = data;

qc++; mc++; }

else { Answer[ ac ] = data; ac++; mc++; } } sc.close(); }

catch(FileNotFoundException fe) {

System.out.println( "File Not Found" ); }

System.out.println( "Questions" );

for(int i = 0; i < qc ; i++) { System.out.println( Question [ i ]); }

System.out.println( "Answer" );

for( int i = 0 ; i < ac ; i++) { System.out.println( Answer[ i ]); }

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

3. How can policymakers influence a nations saving rate?

Answered: 1 week ago