Knowledge Evaluator Software Java Project

by | Aug 28, 2023 | Basic Coding, Java

Home » Coding » Basic Coding » Knowledge Evaluator Software Java Project

Introduction

The Knowledge Evaluator Software Java Project creates knowledge evaluator software. To make the project more interesting, we will be implementing some GUI along with a Random class that helps to generate a random number in a given range & then compare it with the input and generate a message accordingly.

In this project, we create a framework that involves a number of questions that need to be answered by the user or the one who plays the game. We created the input fields using GUI, which takes input from the user, to answer the questions. And these answers will be evaluated by the knowledge evaluator button.

This software is one of the easiest methods to build a Question and Answer game, as it is user-friendly and convenient to use.

Objectives

The Knowledge Evaluator Software Java Project can essentially be divided into objectives that we want to achieve. The first one is to create a user interface involving some graphics and the second objective is to provide the user input options to answer the questions that were designed in the program.

Requirements

1. Java Compiler IDE

2. Swing Module for creation of Graphical User Interface (GUI)

Source Code

package com.company;
public class Main {
public static void main(String[] args) {
new Knowledge();
}
}
package com.company;
import javax.swing.*;
import java.awt.*
public class Knowledge {
private JPanel testPanel;
private JButton SUBMITTESTButton;
private JTextField ans1;
private JTextField ans2;
private JTextField ans3;
private JTextField ans4;
private JTextField ans5;
private int counter = 0;
JFrame testF = new JFrame();
public Knowledge() {
testF.setContentPane(testPanel);
testF.pack();
testF.setLocationRelativeTo(null);
testF.setVisible(true);
SUBMITTESTButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(calc()==0||calc()==1){
JOptionPane.showMessageDialog(null, "LOW IQ. YOUR SCORE IS: "+calc());
}if(calc()==2||calc()==3){
JOptionPane.showMessageDialog(null, "NORMAL IQ. YOUR SCORE IS: "+calc());
}if(calc()==4||calc()==5){
JOptionPane.showMessageDialog(null, "HIGH IQ. YOUR SCORE IS: "+calc());
}
}
});
}
public int calc(){
int count=0;
if(ans1.getText().equalsIgnoreCase("25")){
count++;
} if(ans2.getText().equalsIgnoreCase("envelope")){
count++;
} if(ans3.getText().equalsIgnoreCase("match")){
count++;
} if(ans4.getText().equalsIgnoreCase("p")){
count++;
} if(ans5.getText().equalsIgnoreCase("EJCTNQVVG")){
count++;
}
return count;
}
}

Explanation of the Code

The Knowledge Evaluator Software Java Project code can be broken down into two sections. One involves creating the GUI and the other is generating a random number between 1 to 10 & match it with the user’s input:

1. It consists of a ‘Jtextfield’ that takes input from the user for answers to the questions.

2. It has a button that submits the test.

Moving to retrieving information from the SQL database & updating it according to the user’s input, we will apply the following:

1. It saves all the answers that the user input through ‘textfield’.

2. Evaluate Knowledge button checks for all the answers and returns the message of the number of right answers.

Output

Main Interface

Knowledge Evaluator Software Java Project

Figure 1-Knowledge Evaluator

Conclusion

The Knowledge Evaluator Software Java Project that tests the IQ of a user based on a few questions. If all questions were answered then the application shows a message that you have high IQ otherwise low IQ. It is a very simple and fun application to test a person’s knowledge & can be easily used.

More Java Projects>>>

You May Also Like To Create…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *