Ajay Flow Chart
-
Upload
ajay-rohilla -
Category
Documents
-
view
233 -
download
0
Transcript of Ajay Flow Chart
-
8/10/2019 Ajay Flow Chart
1/85
A
PROJECT REPORT
ON
ONLINE TESTING
SUBMITTED IN THE PARTIAL FULFILMENT OF THE REQUIREMENT
FOR THE AWARD OF THE DEGREE
MASTER
OF
COMPUTER APPLICATION
Submitted to: Submitted by:
Mr Sandeep Maan Neelam
HOD, Roll No
MCA-6
th
SEM
GOVERNMENT COLLEGE, SECTOR-14
GURGAON
-
8/10/2019 Ajay Flow Chart
2/85
2
Contents
1. Certificate
2. Acknowledgement
3.
Introduction to project
4.
Project Plans
5. Introduction to language
6. Project Design
7. Coding
8. Project Testing
9.
Conclusion
10.References
-
8/10/2019 Ajay Flow Chart
3/85
3
CERTIFICATE
This is to certify that Neelam is the student of Computer Science (Third year)
has completed the dissertation entitled ONLINE TESTING under my
supervision and they have completed with all requirements of the ordinance
for the submission of the dissertation. This is their original work and this
report is not submitted elsewhere for award of any degree .I recommend that
dissertation may be sent to evaluation.
Neelam Mr.Sandeep Maan(Name of guide) H.O.D.
-
8/10/2019 Ajay Flow Chart
4/85
4
INTRODUCTION & OVERVIEW OF PROJECT
-
8/10/2019 Ajay Flow Chart
5/85
5
INTRODUCTION & OVERVIEW OF PROJECT
INTRODUCTIONThe project is based on ONLINE TEST. This software firm deals in developing software for its
clients. This Notepad, using Java, Swing and AWT.
In modern civilization has become so complicated and sophisticated that to survive one has to be
competitive. This compiles the people to be acquainted with all type of happening in the society;
mankind is surrounded with a vast amount of data available. Modern business management system has
also rendered in a fashion so that it can be utilized with minimum possible time. Paper files require a
high amount of storage space and storage creates several other problems like fire risk, spoilage and
deterioration by way of aging humidity etc. Computerization of documents and the files has solved this
problem to create extent. Not only this, but it has to be high amount of relaxation to human mind, as
everything can be automated. Now the documents can in a number of ways, styles and number of
documents can be created as and when required without making any mistakes.
The suitable of computerization for an application may be determined as follows:
Volume of storage and calculation:Computerization is best suited to handle large volume of data. The
sufficient, economic and reliable storage characteristic of computer media must be exploited properly.
Quality of Output: Quality of output in terms of accuracy, elegance of output, aesthetics in formality
through use of word processing and powerful editing could justify use of a computer.
Computerized solutions should be cost justifiable: Money, time saving and efficiency justify the cost
of preparing writing and executing a program, Now-computer devices such as calculator can perform
money tasks more economically.
-
8/10/2019 Ajay Flow Chart
6/85
6
PROJECT OVERVIEW
This is an Online Test software, using Java, Swing and AWT. This project does the basic
operation of an Online Test,
In this project all the frames are designed in Swing. Today most programmers use Swing.Swing is a set of classes that provides more powerful and flexible GUI components than
does the AWT. Swing provides the look and feel of the modern Java GUI.
Swing did not exist in the early days of Java. Rather, it was a response to deficienciespresent in Javas original GUI subsystem: the Abstract Window Toolkit. The AWT
defines a basic set of controls, windows, and dialog boxes that support a usable, butlimited graphical interface.
-
8/10/2019 Ajay Flow Chart
7/85
7
PROJECT PLANS
-
8/10/2019 Ajay Flow Chart
8/85
8
PROJECT PLANS
Team Structure
Team Will be comprising of two members.
Our very able and helpful project guide Mr. Ankit.
Development Schedule
The work in developing the new system commented immediately with our first meeting with the
management and users thereafter we were in continuous touch with the management and users of the
company.
Phases Involved in the development of the system
Identify needs and benefits
Held meetings with the management and user
Studied and identified the existing system.
Identify needs and project constraints
Established project statements
Prepared a detailed report of the existing system at work.
Prepare the software requirement specifications .
Actual coding started
SYSTEM DEVELOPMENT LIFE CYCLE MODEL (SDLC MODEL)
This is also known as Classic Life Cycle Model (or) Linear Sequential Model (or) Waterfall Method.
This has the following activities.
1. System/Information Engineering and Modeling
2. Software Requirements Analysis
3. Systems Analysis and Design
4. Code Generation
5. Testing
6. Maintenance
-
8/10/2019 Ajay Flow Chart
9/85
9
System/Information Engineering and Modeling
As software is always of a large system (or business), work begins by establishing
requirements for all system elements and then allocating some subset of these
requirements to software. This system view is essential when software must interface
with other elements such as hardware, people and other resources. System is the basic
and very critical requirement for the existence of software in any entity. So if the system
is not in place, the system should be engineered and put in place. In some cases, to extract
the maximum output, the system should be re-engineered and spruced up. Once the ideal
system is engineered or tuned, the development team studies the software requirement forthe system.
Software Requirement Analysis
This is also known as feasibility study. In this phase, the development team visits the
customer and studies their system. They investigate the need for possible software
automation in the given system. By the end of the feasibility study, the team furnishes a
document that holds the different specific recommendations for the candidate system. It
also includes the personnel assignments, costs, project schedule, and target dates. The
requirements gathering process is intensified and focused specially on software. To
understand the nature of the program(s) to be built, the system engineer ("analyst") must
understand the information domain for the software, as well as required function,
behavior, performance and interfacing. The essential purpose of this phase is to find the
need and to define the problem that needs to be solved.
-
8/10/2019 Ajay Flow Chart
10/85
10
System Analysis and Design
In this phase, the software development process, the software's overall structure and its
nuances are defined. In terms of the client/server technology, the number of tiers needed
for the package architecture, the database design, the data structure design etc are all
defined in this phase. A software development model is created. Analysis and Design are
very crucial in the whole development cycle. Any glitch in the design phase could be
very expensive to solve in the later stage of the software development. Much care is taken
during this phase. The logical system of the product is developed in this phase.
Code generation
The design must be translated into a machine-readable form. The code generation step
performs this task. If the design is performed in a detailed manner, code generation can
be accomplished without much complication. Programming tools like Compilers,
Interpreters, and Debuggers are used to generate the code. Different high level
programming languages like C, C++, Pascal, and Java are used for coding. With respect
to the type of application, the right programming language is chosen.
Testing
Once the code is generated, the software program testing begins. Different testing
methodologies are available to unravel the bugs that were committed during the previous
phases. Different testing tools and methodologies are already available. Some companies
build their own testing tools that are tailor made for their own development operations.
Maintenance
-
8/10/2019 Ajay Flow Chart
11/85
11
Software will definitely undergo change once it is delivered to the customer. There are
many reasons for the change. Change could happen because of some unexpected input
values into the system. In addition, the changes in the system could directly affect the
software operations. The software should be developed to accommodate changes that
could happen during the post implementation period.
-
8/10/2019 Ajay Flow Chart
12/85
12
INTRODUCTION TO LANGUAGE
JAVA
-
8/10/2019 Ajay Flow Chart
13/85
13
INTRODUCTION TO LANGUAGE
JAVA
TECHNOLOGY USED:
The strength of any project depends upon the technology on which the project is based.
Today we are living in a world where technologies related to information technology areevolving every day, new technologies are taking an edge over the older ones. Every new
technology provides some new benefits, but only small part of them remains in thecompetitive world. JAVA is the latest technology, which is in use nowadays and has
proved to be the most reliable development framework.
ABOUT JAVA:
Java technology is both a programming language and a platform.The Java programming language is a high-level language that can be characterized by allof the following buzzwords:
Simple Architecture neutral
Object oriented Portable
Distributed High performance
Multithreaded Robust
Dynamic Secure
In the Java programming language, all source code is first written in plain text filesending with the .java extension. Those source files are then compiled into .class files by
the javac compiler. A .class file does not contain code that is native to your processor; itinstead contains bytecodes the machine language of the Java Virtual Machine1 (Java
VM). The java launcher tool then runs your application with an instance of the JavaVirtual Machine.
http://java.sun.com/docs/books/tutorial/getStarted/intro/definition.html#FOOT#FOOThttp://java.sun.com/docs/books/tutorial/getStarted/intro/definition.html#FOOT#FOOT -
8/10/2019 Ajay Flow Chart
14/85
14
The JAVA PlatformA platform is the hardware or software environment in which a program runs. The Java
platform differs from most other platforms in that it's a software-only platform that runson top of other hardware-based platforms.
The Java platform has two components:
The Java Virtual Machine.
The Java Application Programming Interface (API).
The general-purpose, high-level Java programming language is a powerful software
platform. Every full implementation of the Java platform gives you the followingfeatures:
Development Tools: The development tools provide everything you'll need forcompiling, running, monitoring, debugging, and documenting your applications. As anew developer, the main tools you'll be using are the javac compiler, the java launcher,
and the javadoc documentation tool.
Application Programming Interface (API):The API provides the core functionality ofthe Java programming language. It offers a wide array of useful classes ready for use in
your own applications. It spans everything from basic objects, to networking andsecurity.
User Interface Toolkits: The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs).
Class Thread: A thread is a thread of execution in a program. The Java Virtual Machineallows an application to have multiple threads of execution running concurrently. Every
thread has a priority. Threads with higher priority are executed in preference to threadswith lower priority. When code
-
8/10/2019 Ajay Flow Chart
15/85
15
-
8/10/2019 Ajay Flow Chart
16/85
16
PROJECT DESIGN
-
8/10/2019 Ajay Flow Chart
17/85
17
PROJECT DESIGN
Dialog Box for Student Name.
-
8/10/2019 Ajay Flow Chart
18/85
18
-
8/10/2019 Ajay Flow Chart
19/85
19
-
8/10/2019 Ajay Flow Chart
20/85
20
ER DIAGRAM
-
8/10/2019 Ajay Flow Chart
21/85
21
PROJECT CODING
-
8/10/2019 Ajay Flow Chart
22/85
22
PROJECT CODING
import java.awt. *;
import java.awt. event.*;
import javax.swing.*;
class QuestionSeries
{
static String info ="Java Online Test Week \n \nINSTRUCTIONS:\nThere are 25
questions in this test and 10 minutes to complete them all.\nThe finish button is
highlighted in blue when you reach the end of the test. \nClicking the finish button will
display the results with the correct answers marked in light red. \n \nThe timecounter
begins when you click on the 'start' button \n \nBest of luck!\n";
static String []question =
{"Question 1:\nWhat is the result of attempting to compile and run the following
program?\n\npublic class JavaAppclass{\npublic static void main(String args){\n String
myString = \"javaprograms\";\n System.out.println(myString);\n }\n}\n",
"Question 2:\nWhat is the result of attempting to compile and run the following programwith \n\n>javac JavaApp.java\n>java JavaApp\n\nclass TryFirst{\n String myString =
\"javatest\";\n}\n\nclass JavaApp{\n\npublic static void main(String[] arg){\n
System.out.println(new TryFirst().myString);\n}\n}\n",
-
8/10/2019 Ajay Flow Chart
23/85
23
"Question 3: \nWhat is the result of attempting to compile and run the following
program with \n>javac JavaApp.java\n>java JavaApp\n\nclass MyJavaApp{ \n String
myString = \"elephants\"; \npublic static void main(String[] arg){ \n
System.out.println(myString); \n } \n}\n",
"Question 4:\nWhat is the result?\n\nclass JavaApp{ \n public static void main(String[]
a){ \n String textstr = \"hello\";\n for (int i=4; i
-
8/10/2019 Ajay Flow Chart
24/85
-
8/10/2019 Ajay Flow Chart
25/85
25
"Question 17:\nWhat is the result of this program?\n\nclass MyJavaApp{ \n public static
void main(String[] arg){\n int Num1 = 5;\n int Num2 = 4;\n double d =1.25
+Num1/Num2;\n System.out.println(d); \n } \n}\n",
"Question 18:\nWhat is the result of this program?\n\nclass TryJavaApp{ \n static float
f;\n public static void main(String[] ar){\n int Number = 5;\n f = 1.25; \n
System.out.println(f*4); \n } \n}\n",
"Question 19:\nWhat is the result of this program?\n\nclass JavaApp{ \n static float f;\n
public static void main(String[] ar){\n int Num = 2;\n f = (float)1.25 * 2; \n
System.out.println(f * Num); \n } \n}\n",
"Question 20:\nWhat is the result of this program?\n\nclass HelloJavaApp{ \n public
static void main(String[] ar){\n byte num = 64;\n num += num;\n
System.out.println(num); \n } \n}\n",
"Question 21:\nWhat is the result of this program?\n\nclass JavaApp{ \n public static
void main(String[] a){\n double d = 1.56789;\n long num = Math.round(d);\n
System.out.println(num); \n } \n}\n",
"Question 22:\nWhat is the result of this program?\n\nclass JavaApp{ \n public static
void main(String[] a){\n double d = 1.56789;\n int num = (int)Math.round(d * d);\n
System.out.println(num); \n } \n}\n",
"Question 23:\nWhat is the result of this program?\n\nclass MyJavaApp{\npublic static
void main(String[] arg){\n double doub1 = 1.51;\n int number1 = (int) (doub1
+0.5);\n System.out.println(number1); \n double doub2 = -1.51;\n int number2 =
(int) (doub2 +0.5);\n System.out.println(number2); \n } \n}\n",
-
8/10/2019 Ajay Flow Chart
26/85
26
"Question 24:\nWhat is the result of this program?\n\nclass TryApp{ \npublic static void
main(String[] arg){\n int num = 4;\n num = (num + 4/2) % num+1;\n
System.out.println(num); \n } \n}\n",
"Question 25:\nWhat is the result?\n\nclass MyApp{ \n public static void main(String[]
ar){\n for(int i=0; ijava JavaApp\n","The program is
fine, but we will need another program to run it and get the output.\n","It will compile
and run and output \"java\" to the screen\n"},
{"It will not compile as you cannot have 2 java source files on the same page\n"," \nIt
will output \"javatest","It will not compile as the String myString is not-static and it is
being accessed from a static method\n"," \nIt compiles but there is no output at
runtime\n"},
{" \nFine - it will output elephants\n","Runtime error MyJavaApp is not
public\n","Compiler error myString is a non-static variable being accessed in a static
method\n","Compile error in the main() method\n"},
{" \nIt will output hello\n","The out put will be \nhello\nhello\n"," \nNo output the for
loop needs a ' ; ' at the end\n"," \nCompilation error for loops have to start with a
zero\n"},
{" \n3\n"," \n6\n"," \n4\n"," \n2\n"},
{" \n17\n"," \n5\n"," \n3\n","It won't compile\n"},
{" \n14\n"," \n7\n"," \n17\n"," \nError.\n"},
{" \n16\n"," \n14\n"," \n7\n"," \nError\n"},
{" \n15\n"," \n23\n"," \n50\n"," \nError\n"},
-
8/10/2019 Ajay Flow Chart
27/85
27
{" \n1\n"," \nYou cannot predict the random result\n"," \n0\n"," \nError\n"},
{" \n6\n"," \n5\n"," \n0\n"," \nError\n"},
{" \n4\n"," \n3\n"," \n0\n"," \nError\n"},
{" \n00001010\n"," \n10\n"," \n1010\n"," \nError\n"},
{"hello java world\n"," \nhello\n"," \njava\n"," \nworld\n"},
{" \n1.75\n"," \n2\n"," \n3\n"," \nError\n"},
{" \n3.25\n"," \n2.25\n"," \n2.2... and a very long number\n"," \nThe code will not
compile\n"},
{" \n2.5\n"," \n2.25\n"," \n2.2 ... -something and a very long number\n"," \nThe code will
not compile\n"},
{" \nError float f is not initialised\n"," \noutput: 5\n"," \noutput: 5.0\n"," \nError, this is
not a valid way to initialise a float type variable\n"},
{" \n4.0\n"," \n5\n"," \n5.0\n"," \nError, it will not compile\n"},
{" \n128\n"," \n-128\n"," \n1\n"," \nError, number is out of range\n"},
{" \n1\n"," \n2\n"," \n1.0\n"," \nError\n"},
{"3. - and to 15 decimal places\n"," \n2\n"," \n3\n"," \nError\n"},
{" 2 \n-2\n"," 1\n-2\n"," 2\n-1\n"," 1\n-1\n"},
{" \n1\n"," \n3\n"," \n4\n"," \n6\n"},
{"1,2,2,3,3,4\n","1,2,3,3,4,6\n","1,2,3,4\n"," \n0,1,1,2,2,3,3,4\n"}
};
static int [] n = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1};
Static string []choice={"23","2","3","1","1","4","4","3","4","3","4","1",
"3","3","4","4","2","4","3","2","2","3","3","2","1"};
static int tally = choice.length;
static String testtitle="Java Programming Online Test";
static int timeLimit =10;
static int passMark = 15;
-
8/10/2019 Ajay Flow Chart
28/85
28
}
/* OnlineTest class */
public class Main extends JFrame{
static String studentname ="";
static int TOTAL=0;
static {
try{
TOTAL = QuestionSeries.tally;
/* The input window */
studentname = JOptionPane.showInputDialog("Enter your name: ");
if (studentname.length() < 1)
studentname = "Anonymous ";
else
studentname = studentname.trim() + " ";
}
catch(NullPointerException e){ System.exit(0); }
}
-
8/10/2019 Ajay Flow Chart
29/85
29
int seconds, minutes;
int quesnum, itemCheck, mark;
final String TESTTITLE = QuestionSeries.testtitle;
final int TIMELIMIT = QuestionSeries.timeLimit;
final int PASS = QuestionSeries.passMark;
String []answers = new String[TOTAL];
JButton []choice_button = new JButton[6];
JTextArea answerboxes[] = new JTextArea[4];
JCheckBox []boxes = new JCheckBox[4];
JTextPane pane = new JTextPane();
JLabel student, choose, message, timecounter, testresult;
boolean start_test, check_answer, allowRestart, finishtest;
Northwindow panelNorth = new Northwindow();
Southwindow panelSouth = new Southwindow();
Centerwindow panelCenter = new Centerwindow();
/* OnlineTest Constructor */
protected Main(){
for (int i=0; i
-
8/10/2019 Ajay Flow Chart
30/85
30
setSize(width,height);
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setLocation((dim.width-width)/2, (dim.height-height)/2);
}
/**** Northwindow class**/
class Northwindow extends JPanel
{
/**** Northwindow constructor **/
public Northwindow()
{
-
8/10/2019 Ajay Flow Chart
31/85
31
setLayout(new GridLayout(2,2));
setBackground(new Color(230, 230, 255));
student = new JLabel("\t Welcome : "+studentname+" to the Online Java
Test");
student.setFont(new Font("",Font.BOLD,16) );
message = new JLabel();
message.setForeground(Color.blue);
add(student);
add(message);
add(new JLabel(" ") );
add(new JLabel(" ") );
setBorder(BorderFactory.createEtchedBorder() );
}
}
/**** Southwindow class **/
class Southwindow extends JPanel
{
public Southwindow()
{
String []key = {"","start:","next:","finish:","check next:","check previous:"};
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
32/85
32
}
}
/**** Centerwindow class **/
class Centerwindow extends JPanel
{
public Centerwindow()
{
setLayout(new GridLayout(1,2) );
JScrollPane west = new JScrollPane(pane);
pane.setForeground(Color.red);
pane.setFont(new Font ("monospaced",0,12) );
pane.setText(QuestionSeries.info);
pane.setEditable(false);
JPanel east = new JPanel();
east.setLayout(new BorderLayout() );
JPanel northEast = new JPanel();
northEast.setBackground(new Color(230, 230, 255) );
east.add("North", northEast);
JPanel westEast = new JPanel();
westEast.setLayout(new GridLayout(6,1) );
east.add("West", westEast);
JPanel centerEast = new JPanel();
centerEast.setLayout(new GridLayout(6,1) );
centerEast.setBackground(new Color(255,255,200));
east.add("Center", centerEast);
timecounter = new JLabel(" There are "+TOTAL+" questions in total");
timecounter.setFont(new Font ("Arial",Font.BOLD,16) );
-
8/10/2019 Ajay Flow Chart
33/85
-
8/10/2019 Ajay Flow Chart
34/85
34
testresult = new JLabel(studentname+", You have only : "+TIMELIMIT+"
minutes to complete.");
else
testresult = new JLabel(" There is no time limit for this test");
testresult.setBorder(BorderFactory.createEtchedBorder() );
centerEast.add(testresult);
add(west);
add(east);
}
}
/**** ActionHandler class to handle all the action events from the buttons. **/
class ActionHandler implements ActionListener{
/* actionPerformed method */
public void actionPerformed(ActionEvent evt){
String source = evt.getActionCommand();
If (source.equals("start:"))
{
choice_button[1].setVisible(false);
start_test=true;
allowRestart=true;
if (TIMELIMIT >0)new Timer(); // inner Timer class
panelSouth.remove(choice_button[1]); //start
displayquestion();
}
-
8/10/2019 Ajay Flow Chart
35/85
35
If (start_test)
{
If (source.equals("previous:"))
{
recordanswer();
quesnum--;
if (quesnum == -1)
quesnum=TOTAL-1;
checkteststatus();
displayquestion();
}
If (source.equals("next:"))
{
Recordanswer ();
Quesnum++;
if(quesnum == TOTAL-1) finishtest=true;
if(quesnum == TOTAL) quesnum=0;
checkteststatus();
displayquestion();
}
If (source.equals("finish:"))
{
if (finishtest)
{
recordanswer();
quesnum = 0;
choice_button[4].setBackground(Color.lightGray);
timecounter.setForeground(Color.blue);
-
8/10/2019 Ajay Flow Chart
36/85
36
timecounter.setFont(new Font ("Arial",0,14) );
start_test=false;
check_answer=true;
panelSouth.add(choice_button[0]);
mark_ques();
displayquestion();
checkteststatus();
calculateResult();
}
Else
JOptionPane.showMessageDialog(null,"Cycle through all questions
before pressing finish",
"User Message",JOptionPane.INFORMATION_MESSAGE);
}
}
if (check_answer)
{
if (source.equals("check next:"))
{
quesnum++;
if(quesnum == TOTAL) quesnum=0;
mark_ques();
displayquestion();
checkteststatus();
}
if(source.equals("check previous:"))
-
8/10/2019 Ajay Flow Chart
37/85
37
{
quesnum--;
if(quesnum == -1) quesnum=TOTAL-1;
mark_ques();
displayquestion();
checkteststatus();
}
}
validate();
}
/* Timer class */
class Timer extends Thread implements Runnable
{
public Timer()
{
new Thread(this).start();
}
public void run()
{
while(start_test)
{
try {
Thread.sleep(1000);
seconds++;
if (seconds % 60 == 0 && seconds != 0)
{ seconds = 60;
-
8/10/2019 Ajay Flow Chart
38/85
38
minutes++;
}
timecounter.setText ("Time Counter: "+minutes+" mins : "+seconds+" secs ");
if (minutes==TIMELIMIT)
{ start_test=false;
endTest();
}
}
catch(InterruptedException ex) { System.out.print(ex); }
}
}
}
/* checkteststatus method */
public void checkteststatus()
{
if [( quesnum == TOTAL-1)&&
(start_test))choice_button[3].setBackground(Color.green)];
Else
choice_button[4].setBackground(Color.lightGray);
if (answers[quesnum].length() >0)
{
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
39/85
39
boxes[i].setSelected(false);
}
/* displayquestion method */
public void displayquestion()
{
int j = quesnum+1;
pane.setText(QuestionSeries.question[quesnum]);
if (start_test)message.setText("Question "+j+" out of "+TOTAL);
for (int i=0; i
-
8/10/2019 Ajay Flow Chart
40/85
40
temp="
ALL are true true";
choose.setText(temp);
}
Else
{
timecounter.setText(" Your choices are shown in the boxes");
choose.setText(" Correct answers are marked in light red.");
}
}
/* record answer method */
public void recordanswer(){
String tmp = "";
For (int i=0; i
-
8/10/2019 Ajay Flow Chart
41/85
-
8/10/2019 Ajay Flow Chart
42/85
42
public void calculateResult()
{
mark=0;
double temp=0.0;
java.text.DecimalFormat df = new java.text.DecimalFormat("#0.#");
for (int i=0; i=PASS)
testresult.setText(" Well done "+studentname.substring(0,
studentname.indexOf(' ') )+", you passed");
else
testresult.setText("Better luck next time "
+studentname.substring(0,studentname.indexOf(' ') ) );
student.setText(" Final score for "+studentname+": "+mark+" out of
"+TOTAL+": "+df.format(temp/TOTAL*100)+"%");
new Resultwindow().show();
}
}
/* Resultwindow class */
class Resultwindow extends JFrame{
Resultwindow() {
super( studentname+" results: " +(mark*100/TOTAL >=PASS?"PASS":"FAIL") );
Container cont = getContentPane();
cont.setLayout(new GridLayout(TOTAL/2+3,5,2,5) );
-
8/10/2019 Ajay Flow Chart
43/85
-
8/10/2019 Ajay Flow Chart
44/85
44
"There is only "+QuestionSeries.n[quesnum]+" possible
answer to question"+(quesnum+1)+
"","User Information
Message",JOptionPane.INFORMATION_MESSAGE);
else JOptionPane.showMessageDialog(null,""+
"There are only "+QuestionSeries.n[quesnum]+" possible
answers toquestion "+(quesnum+1)+
"","User Information
Message",JOptionPane.INFORMATION_MESSAGE);
}
itemCheck=0;
}
}
}
-
8/10/2019 Ajay Flow Chart
45/85
45
/* main method */
public static void main(String [] args)
{
Main frame = new Main();
frame.setTitle(" "+QuestionSeries.testtitle);
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.setVisible(true);
}
}
-
8/10/2019 Ajay Flow Chart
46/85
46
PROJECT ONLINE TEST
package onlinetest;
/import java.awt. *;
import java.awt. event.*;
import javax.swing.*;
class QuestionSeries
{
static String info ="Java Online Test Week \n \nINSTRUCTIONS:\nThere are 25
questions in this test and 10 minutes to complete them all.\nThe finish button is
highlighted in blue when you reach the end of the test. \nClicking the finish button will
display the results with the correct answers marked in light red. \n \nThe timecounter
begins when you click on the 'start' button \n \nBest of luck!\n";
static String []question ={"Question 1:\nWhat is the result of attempting to compile and
run the following program?\n\npublic class JavaAppclass{\npublic static void
main(String args){\n String myString = \"javaprograms\";\n
System.out.println(myString);\n }\n}\n",
-
8/10/2019 Ajay Flow Chart
47/85
47
"Question 2:\nWhat is the result of attempting to compile and run the following program
with \n\n>javac JavaApp.java\n>java JavaApp\n\nclass TryFirst{\n String myString =
\"javatest\";\n}\n\nclass JavaApp{\n\npublic static void main(String[] arg){\n
System.out.println(new TryFirst().myString);\n}\n}\n",
"Question 3: \nWhat is the result of attempting to compile and run the following
program with \n>javac JavaApp.java\n>java JavaApp\n\nclass MyJavaApp{ \n String
myString = \"elephants\"; \npublic static void main(String[] arg){ \n
System.out.println(myString); \n } \n}\n",
"Question 4:\nWhat is the result?\n\nclass JavaApp{ \n public static void main(String[]
a){ \n String textstr = \"hello\";\n for (int i=4; i
-
8/10/2019 Ajay Flow Chart
48/85
48
"Question 8:\nWhat is the result?\n\nclass JavaApp{ \n static int number1 = 4;\n public
static void main(String[] a){ \n number1=2;\n int number2 = 7;\n number2=
number1 * 2 +3;\n System.out.println(number2); \n } \n}\n",
"Question 9:\nWhat is the result?\n\nclass JavaApp{ \n static int number1 = 3;\n public
static void main(String[] arg)\n int number2 = 7;\n number2= number2 + number1 * 2
+3;\n System.out.println(number2); \n } \n}\n",
"Question 10:\nWhat is the result of compiling and running the following code?\n\nclass
JavaApp{ \n public static void main(String[] a){\n int x = (int) (Math.random());\n
System.out.println(x); \n } \n}\n",
"Question 11:\nWhat is the result?\n\nclass Tryclass{ \n static String text = \"rabbit\";\n
public static void main(String[] a){\n int num = text.length;\n
System.out.println(num); \n } \n}\n",
"Question 12:\nWhat would be the result here?\n\nclass Myclass{ \n public static void
main(String[] a){\n char []rabbit={'a','b','c','d'};\n int num = rabbit.length;\n
System.out.println(num); \n } \n}\n",
"Question 13:\nWhat is the result here?\n\nclass JavaApp{ \n public static void
main(String[] a){\n int number = 10;\n String mystr =
Integer.toBinaryString(number);\n System.out.println(mystr); \n } \n}\n",
"Question 14:\nWhat would be the result if we were to run this program with\n>java
MyJavaApp hello java world ?\n\nclass MyJavaApp{ \npublic static void main(String[]
args){\n System.out.println(args[1]); \n } \n}\n",
-
8/10/2019 Ajay Flow Chart
49/85
49
"Question 15:\nWhat is the result of this program?\n\nclass MyJavaApp{ \n public
static void main(String[] a){\n double d =1.75;\n int i = d;\n
System.out.println(i++); \n } \n}\n",
"Question 16:\nWhat is the result of this program?\n\nclass MyJavaApp{ \n public
static void main(String[] a){\n int 1stNum = 5;\n int 2ndNum = 3;\n double d =1.25
+1stNum/2ndNum;\n System.out.println(d); \n } \n}\n",
"Question 17:\nWhat is the result of this program?\n\nclass MyJavaApp{ \n public static
void main(String[] arg){\n int Num1 = 5;\n int Num2 = 4;\n double d =1.25
+Num1/Num2;\n System.out.println(d); \n } \n}\n",
"Question 18:\nWhat is the result of this program?\n\nclass TryJavaApp{ \n static float
f;\n public static void main(String[] ar){\n int Number = 5;\n f = 1.25; \n
System.out.println(f*4); \n } \n}\n",
"Question 19:\nWhat is the result of this program?\n\nclass JavaApp{ \n static float f;\n
public static void main(String[] ar){\n int Num = 2;\n f = (float)1.25 * 2; \n
System.out.println(f * Num); \n } \n}\n",
"Question 20:\nWhat is the result of this program?\n\nclass HelloJavaApp{ \n public
static void main(String[] ar){\n byte num = 64;\n num += num;\n
System.out.println(num); \n } \n}\n",
"Question 21:\nWhat is the result of this program?\n\nclass JavaApp{ \n public static
void main(String[] a){\n double d = 1.56789;\n long num = Math.round(d);\n
System.out.println(num); \n } \n}\n",
-
8/10/2019 Ajay Flow Chart
50/85
50
"Question 22:\nWhat is the result of this program?\n\nclass JavaApp{ \n public static
void main(String[] a){\n double d = 1.56789;\n int num = (int)Math.round(d * d);\n
System.out.println(num); \n } \n}\n",
"Question 23:\nWhat is the result of this program?\n\nclass MyJavaApp{\npublic static
void main(String[] arg){\n double doub1 = 1.51;\n int number1 = (int) (doub1
+0.5);\n System.out.println(number1); \n double doub2 = -1.51;\n int number2 =
(int) (doub2 +0.5);\n System.out.println(number2); \n } \n}\n",
"Question 24:\nWhat is the result of this program?\n\nclass TryApp{ \npublic static void
main(String[] arg){\n int num = 4;\n num = (num + 4/2) % num+1;\n
System.out.println(num); \n } \n}\n",
"Question 25:\nWhat is the result?\n\nclass MyApp{ \n public static void main(String[]
ar){\n for(int i=0; i
-
8/10/2019 Ajay Flow Chart
51/85
51
static String [][]answers ={{"It will not compile as the main method String is not an
array\n","It will compile but there will be a runtime error if we try to run it with:- \n>java
JavaApp\n","The program is fine, but we will need another program to run it and get the
output.\n","It will compile and run and output \"java\" to the screen\n"},{"It will not
compile as you cannot have 2 java source files on the same page\n"," \nIt will output
\"javatest","It will not compile as the String myString is not-static and it is being accessed
from a static method\n"," \nIt compiles but there is no output at runtime\n"},{" \nFine - it
will output elephants\n","Runtime error MyJavaApp is not public\n","Compiler error
myString is a non-static variable being accessed in a static method\n","Compile error in
the main() method\n"},{" \nIt will output hello\n","The out put will be
\nhello\nhello\n"," \nNo output the for loop needs a ' ; ' at the end\n"," \nCompilation
error for loops have to start with a zero\n"},{" \n3\n"," \n6\n"," \n4\n"," \n2\n"},{"
\n17\n"," \n5\n"," \n3\n","It won't compile\n"},{" \n14\n"," \n7\n"," \n17\n","
\nError.\n"},{" \n16\n"," \n14\n"," \n7\n"," \nError\n"},{" \n15\n"," \n23\n"," \n50\n","
\nError\n"},{" \n1\n"," \nYou cannot predict the random result\n"," \n0\n","
\nError\n"},{" \n6\n"," \n5\n"," \n0\n"," \nError\n"},{" \n4\n"," \n3\n"," \n0\n","
\nError\n"},{" \n00001010\n"," \n10\n"," \n1010\n"," \nError\n"},{"hello java world\n","
\nhello\n"," \njava\n"," \nworld\n"},{" \n1.75\n"," \n2\n"," \n3\n"," \nError\n"},{"
\n3.25\n"," \n2.25\n"," \n2.2... and a very long number\n"," \nThe code will not
compile\n"},{" \n2.5\n"," \n2.25\n"," \n2.2 ... -something and a very long number\n","
\nThe code will not compile\n"},{" \nError float f is not initialised\n"," \noutput: 5\n","
-
8/10/2019 Ajay Flow Chart
52/85
52
\noutput: 5.0\n"," \nError, this is not a valid way to initialise a float type variable\n"},{"
\n4.0\n"," \n5\n"," \n5.0\n"," \nError, it will not compile\n"},{" \n128\n"," \n-128\n","
\n1\n"," \nError, number is out of range\n"},{" \n1\n"," \n2\n"," \n1.0\n","
\nError\n"},{"3. - and to 15 decimal places\n"," \n2\n"," \n3\n"," \nError\n"},{" 2 \n-
2\n"," 1\n-2\n"," 2\n-1\n"," 1\n-1\n"},{" \n1\n"," \n3\n"," \n4\n","
\n6\n"},{"1,2,2,3,3,4\n","1,2,3,3,4,6\n","1,2,3,4\n"," \n0,1,1,2,2,3,3,4\n"} };
static int []n = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
static String []choice=
{"23","2","3","1","1","4","4","3","4","3","4","1","3","3","4","4","2","4","3","2","2","3","
3","2","1"};
static int tally = choice.length;
static String testtitle="Java Programming Online Test";
static int timeLimit =10;
static int passMark = 15;
}
/* OnlineTest class */
public class Main extends JFrame{
static String studentname ="";
-
8/10/2019 Ajay Flow Chart
53/85
53
static int TOTAL=0;
static {
try{
TOTAL = QuestionSeries.tally;
/* The input window */
studentname = JOptionPane.showInputDialog("Enter your name: ");
if(studentname.length() < 1) studentname = "Anonymous ";
else studentname = studentname.trim() + " ";
}catch(NullPointerException e){ System.exit(0); }
}
int seconds, minutes;
int quesnum, itemCheck, mark;
final String TESTTITLE = QuestionSeries.testtitle;
final int TIMELIMIT = QuestionSeries.timeLimit;
final int PASS = QuestionSeries.passMark;
String []answers = new String[TOTAL];
JButton []choice_button = new JButton[6];
JTextArea answerboxes[] = new JTextArea[4];
JCheckBox []boxes = new JCheckBox[4];
-
8/10/2019 Ajay Flow Chart
54/85
54
JTextPane pane = new JTextPane();
JLabel student, choose, message, timecounter, testresult;
boolean start_test, check_answer, allowRestart, finishtest;
Northwindow panelNorth = new Northwindow();
Southwindow panelSouth = new Southwindow();
Centerwindow panelCenter = new Centerwindow();
/* OnlineTest Constructor */
protected Main(){
for (int i=0; i
-
8/10/2019 Ajay Flow Chart
55/85
55
setLocation((dim.width-width)/2, (dim.height-height)/2);
}
/**
** Northwindow class
**/
class Northwindow extends JPanel{
/**
** Northwindow constructor
**/
public Northwindow(){
setLayout(new GridLayout(2,2));
setBackground(new Color(230, 230, 255));
student = new JLabel("\t Welcome : "+studentname+" to the Online Java
Test");
student.setFont(new Font("",Font.BOLD,16) );
message = new JLabel();
message.setForeground(Color.blue);
add(student);
-
8/10/2019 Ajay Flow Chart
56/85
56
add(message);
add(new JLabel(" ") );
add(new JLabel(" ") );
setBorder(BorderFactory.createEtchedBorder() );
}
}
/**
** Southwindow class
**/
class Southwindow extends JPanel{
public Southwindow(){
String []key = {"","start:","next:","finish:","check next:","check previous:"};
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
57/85
57
}
/**
** Centerwindow class
**/
class Centerwindow extends JPanel{
public Centerwindow(){
setLayout(new GridLayout(1,2) );
JScrollPane west = new JScrollPane(pane);
pane.setForeground(Color.red);
pane.setFont(new Font ("monospaced",0,12) );
pane.setText(QuestionSeries.info);
pane.setEditable(false);
JPanel east = new JPanel();
east.setLayout(new BorderLayout() );
JPanel northEast = new JPanel();
northEast.setBackground(new Color(230, 230, 255) );
east.add("North", northEast);
JPanel westEast = new JPanel();
westEast.setLayout(new GridLayout(6,1) );
-
8/10/2019 Ajay Flow Chart
58/85
58
east.add("West", westEast);
JPanel centerEast = new JPanel();
centerEast.setLayout(new GridLayout(6,1) );
centerEast.setBackground(new Color(255,255,200));
east.add("Center", centerEast);
timecounter = new JLabel(" There are "+TOTAL+" questions in
total");
timecounter.setFont(new Font ("Arial",Font.BOLD,16) );
timecounter.setForeground(new Color(0,90,20) );
northEast.add(timecounter);
westEast.add(new JLabel(" "));
String []boxs = {" A ", " B ", " C ", " D "};
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
59/85
59
JScrollPane panes[] = new JScrollPane[4];
for(int i=0; i0)testresult = new JLabel(studentname+", You have only :
"+TIMELIMIT+" minutes to complete.");
else testresult = new JLabel(" There is no time limit for this test");
testresult.setBorder(BorderFactory.createEtchedBorder() );
centerEast.add(testresult);
add(west);
add(east);
}
}
-
8/10/2019 Ajay Flow Chart
60/85
60
/**
** ActionHandler class to handle all the action events from the buttons.
**/
class ActionHandler implements ActionListener{
/* actionPerformed method */
public void actionPerformed(ActionEvent evt){
String source = evt.getActionCommand();
if(source.equals("start:")){
choice_button[1].setVisible(false);
start_test=true;
allowRestart=true;
if(TIMELIMIT >0)new Timer(); // inner Timer class
panelSouth.remove(choice_button[1]); //start
displayquestion();
}
if(start_test){
if(source.equals("previous:")) {
recordanswer();
quesnum--;
if(quesnum == -1) quesnum=TOTAL-1;
checkteststatus();
displayquestion();
}
if(source.equals("next:")) {
recordanswer();
-
8/10/2019 Ajay Flow Chart
61/85
61
quesnum++;
if(quesnum == TOTAL-1) finishtest=true;
if(quesnum == TOTAL) quesnum=0;
checkteststatus();
displayquestion();
}
if(source.equals("finish:")) {
if (finishtest){
recordanswer();
quesnum = 0;
choice_button[4].setBackground(Color.lightGray);
timecounter.setForeground(Color.blue);
timecounter.setFont(new Font ("Arial",0,14) );
start_test=false;
check_answer=true;
panelSouth.add(choice_button[0]);
mark_ques();
displayquestion();
checkteststatus();
calculateResult();
}
else JOptionPane.showMessageDialog(null,"Cycle through all
questions before pressing finish",
"User Message",JOptionPane.INFORMATION_MESSAGE);
}
}
-
8/10/2019 Ajay Flow Chart
62/85
62
if (check_answer){
if(source.equals("check next:")) {
quesnum++;
if(quesnum == TOTAL) quesnum=0;
mark_ques();
displayquestion();
checkteststatus();
}
if(source.equals("check previous:")) {
quesnum--;
if(quesnum == -1) quesnum=TOTAL-1;
mark_ques();
displayquestion();
checkteststatus();
}
}
validate();
}
/* Timer class */
class Timer extends Thread implements Runnable{
public Timer(){
new Thread(this).start();
}
public void run() {
-
8/10/2019 Ajay Flow Chart
63/85
-
8/10/2019 Ajay Flow Chart
64/85
64
boxes[Integer.parseInt(answers[quesnum].substring(i,i+1) )-
1].setSelected (true);
}
else for(int i=0; i
-
8/10/2019 Ajay Flow Chart
65/85
65
}
else {
timecounter.setText(" Your choices are shown in the boxes");
choose.setText(" Correct answers are marked in light red.");
}
}
/* record answer method */
public void recordanswer(){
String tmp = "";
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
66/85
66
public void mark_ques(){
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
67/85
67
student.setText(" Final score for "+studentname+": "+mark+" out of
"+TOTAL+": "+df.format(temp/TOTAL*100)+"%");
new Resultwindow().show();
}
}
/* Resultwindow class */
class Resultwindow extends JFrame{
Resultwindow() {
super( studentname+" results: " +(mark*100/TOTAL >=PASS?"PASS":"FAIL") );
Container cont = getContentPane();
cont.setLayout(new GridLayout(TOTAL/2+3,5,2,5) );
cont.setBackground(new Color(255,220,255) );
cont.add(new JLabel(" "+"Marks: "+mark+"/"+TOTAL+": "+"Percentage:
"+(mark*100/TOTAL)+"%") );
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
68/85
68
}
for(int i=0; i
-
8/10/2019 Ajay Flow Chart
69/85
69
"","User Information
Message",JOptionPane.INFORMATION_MESSAGE);
else JOptionPane.showMessageDialog(null,""+
"There are only "+QuestionSeries.n[quesnum]+" possible
answers toquestion "+(quesnum+1)+
"","User Information
Message",JOptionPane.INFORMATION_MESSAGE);
}
itemCheck=0;
}
}
}
-
8/10/2019 Ajay Flow Chart
70/85
70
/* main method */
public static void main(String [] args){
Main frame = new Main();
frame.setTitle(" "+QuestionSeries.testtitle);
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.setVisible(true);
} }
-
8/10/2019 Ajay Flow Chart
71/85
71
FLOW CHART
-
8/10/2019 Ajay Flow Chart
72/85
72
FLOW CHART
-
8/10/2019 Ajay Flow Chart
73/85
73
FLOW CHART
-
8/10/2019 Ajay Flow Chart
74/85
74
FLOW CHART
-
8/10/2019 Ajay Flow Chart
75/85
75
FLOW CHART
-
8/10/2019 Ajay Flow Chart
76/85
76
PROJECT TESTING
-
8/10/2019 Ajay Flow Chart
77/85
77
PROJECT TESTING
The basic purpose of the testing phase is to detect the errors that may be present in the
program. However often the aim of testing is to demonstrate that a program works by
showing that it has no errors, this is opposite of what testing should be viewed as .So
testing can be defined as:
TESTING IS THE PROCESS OF EXECUTING A PROGRAM WITH THE INTENT
OF FINDING ERRORS.
Testing is the process of executing a program/system with the intent of finding errors.
The emphasis is on the deliberate intent of finding errors. This is quite different to simply
proving that a program or system works. The fundamental purpose of software testing is
to find problems in the software so that they can be fixed, resulting in code that is more
reliable, stable and more closely matches what the real end-user wants.
Each test report is in the form of a java source file, split into three sections:
1. A summary of the test (date, tester, etc)
2. Test code
3.
Actual test results
-
8/10/2019 Ajay Flow Chart
78/85
78
Therefore each report will have the standard header, and will be self contained and
complete. Software testing is the process of testing the software product. Effective
software testing will contribute to the delivery of higher quality software products ,more
satisfied users ,and lowers maintainance costs ,more accurate and reliable results.
However ,ineffective testing will lead to the opposite results .It is a very expensive
process and consumes one third to one-half of the cost of a typical development project.
The testing of newly developed software , prior to its actual use ,is a commonly followed
practice. It is the process of executing program (or a part of program) with the intention
of finding errors. However, testing cannot show the absence of errors it can only show
that errors are present.
-
8/10/2019 Ajay Flow Chart
79/85
79
ER DIAGRAM
-
8/10/2019 Ajay Flow Chart
80/85
80
1. UNIT TESTING:
The starting point of testing is unit testing. Unit testing is the process of taking a module
and running it in isolation from the rest of the software product by using prepared test
cases and comparing the actual results with the results predicted by the specification and
design of the module. The purpose of this phase (also called the implementation phase) of
software development is to translate the software design in to source code. During the
implementation phase ,each component of the design is implemented as a program
module ,and each of these program modules is unit tested (i.e; tested independently as a
stand alone unit),debugged ,and documented .The purpose of unit testing is to determine
the correct working of the individual modules.The end-product of the implementation
phase is a set of program modules that have been individually tested.
2.INTEGRATION TESTING:
Integration testing follows unit testing. It is performed to determine that the interface
between modules is also correct .One specific target of integration testing is the interface:
whether parameters match on both sides as to type ,permissible ranges, meaning and
utilization .During integration testing the focus is on interconnections between various
components.
-
8/10/2019 Ajay Flow Chart
81/85
81
-
8/10/2019 Ajay Flow Chart
82/85
82
CONCLUSIONS
-
8/10/2019 Ajay Flow Chart
83/85
83
Conclusions
This project that I undertook was truly a very rewarding experience for me in
more than one way. It has given a big thrust to my technical knowledge as
prospective Software professional. It has also helped me enhance my skills on
the personal front.
And I feel extremely satisfied by the fact that I have managed to develop the
project of course with equal contribution from my team members. I think I
have exploited the opportunity that came my way to the fullest extent by
increasing my technical know-how and also gaining the valuable work
experience apart from studying the other subjects in our curriculum.
-
8/10/2019 Ajay Flow Chart
84/85
84
REFERENCES
-
8/10/2019 Ajay Flow Chart
85/85
References
Complete reference in Java by Patrick Naughton
Complete reference in Java 2 by Herbert Schildt
Programming in Java by E.Balagursamy.
Www. google .com
www.java.co.in
http://www.google/http://www.google/