This study material provides information on object oriented design and programming. It includes pseudo code, testing, user guide, assumptions, bugs/errors, suggestions, and codes.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head:OBJECT ORIENTED DESIGN AND PROGRAMMING Object Oriented Design and Programming Name of the Student Name of the University Author’s note:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
1OBJECT ORIENTED DESIGN AND PROGRAMMING Table of Contents Pseudo Code:...................................................................................................................................2 Testing:............................................................................................................................................3 User Guide:......................................................................................................................................6 Assumptions:...................................................................................................................................7 Bugs/Errors:.....................................................................................................................................7 Suggestions:.....................................................................................................................................7 Codes:..............................................................................................................................................7 Bibliography:.................................................................................................................................11
2OBJECT ORIENTED DESIGN AND PROGRAMMING Pseudo Code: Initialize the private scanner variable as x Initialize another scanner variable as input Initialize the array of object called a Initialize variable i and z Assign value 1 to z Create a method named execute Initialize the read.txt file to be read by java private scanner x Initialize to write into the file named new.txt using FileWriter’s object fw Initialize PrintWriter as pw to the object called fw While the read.txt file will have value in each line the array of objects will store it If z is 0 then fourth and fifth position values will be task4 and grade Then increase z If the z is greater than 1 Then user will provide fourth and fifth position values Each loop will store the data into new.txt using pw object After loop is complete, the new.txt file will be closed Now all the values stored in new.txt will be read using array of objects
3OBJECT ORIENTED DESIGN AND PROGRAMMING Instead of storing it, the values will be shown in each loop to the java console The read.txt file will be closed Testing: Test Case 1: Input Data are as following StudentTask1 Task2 Task3 19.518.025.5 29.019.020.0 35.012.518.0 48.516.022.0 57.011.025.0 The following data has been inputted into the system.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
4OBJECT ORIENTED DESIGN AND PROGRAMMING All these data were successfully accepted by the program The output was like following. Test Case 3: Input Data are as following StudentTask1 Task2 Task3 19.518.025.5 29.019.020.0 35.012.518.0
5OBJECT ORIENTED DESIGN AND PROGRAMMING 48.516.022.0 57.011.025.0 The following data has been inputted into the system. All these data were successfully accepted by the program The output was like following. Test Case 3: Input Data are as following StudentTask1 Task2 Task3
6OBJECT ORIENTED DESIGN AND PROGRAMMING 19.518.025.5 29.019.020.0 35.012.518.0 48.516.022.0 57.011.025.0 The following data has been inputted into the system. All these data were successfully accepted by the program The output was like following.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
7OBJECT ORIENTED DESIGN AND PROGRAMMING User Guide: The user will run the application in Java IDE. After the main class is initialized, the console will ask to enter marks and grades of students. The user will click on console output area and enter the relevant values. After the marks and grades are entered, for all the five student’s, the console will show what exactly has been stored in the output file. Assumptions: During the development of the Java application, it is assumed that the teachers will calculate the grade on their own. It is also assumed that the array of object and FileWriter class can be used to make the programming most effective and effecient. As the input file does not have the headers task4 and grade. It was assumed that a login has to be put that can differentiate what is header and what is actual value. Bugs/Errors: There are no bugs in the application right now. All the codes are intact and functioning. There are no codes which can be used to exploit the application. Suggestions: It is suggested that automatic Grade calculation is integrated into the application in future. Moreover, a GUI based application will be much efficient than a console based. Codes: Main Class: package studentresult; import java.io.*;
8OBJECT ORIENTED DESIGN AND PROGRAMMING import java.util.*; import static java.lang.System.*; import java.util.Scanner; //importing scanner class public class main { private Scanner x; //initializing the scanner class access modifier to private Scanner input = new Scanner(System.in); //creating the input object of scanner class String a[][] = new String[6][6]; //defining a 2d array of String int i; //defining i variable int j =0; // initializing j variable int z =0;// initializing z variable public void execute() { //method for reading file and copying the data into another file try { x=new Scanner (new File("read.txt")); //initializing which file to read FileWriter fw = new FileWriter("new.txt"); //initializing which file to write PrintWriter pw = new PrintWriter(fw); //creating pw object of PrintWriter class with fw as parameter z=0; while(x.hasNext()){//willexecuteinsidestatementsuntil redFile.txt has unread data if(z==0) { //check if z's value is 0 i=0; //initialize i variable a[z][i++]=x.next(); //assign the first row value to 2d array a[z][i++] =x.next(); a[z][i++] =x.next();
9OBJECT ORIENTED DESIGN AND PROGRAMMING a[z][i++] =x.next(); pw.println(a[z][0] + " " + a[z][1] + " " + a[z][2] + " " + a[z][3] + " Task4 Grade"); //write the 2d array data and " Task4 Grade" in new.txt file's first row z++; } else { //this block is executed when z's value is more than 0 i=0; //this statement initializes i's value to 0 everytime loop is called. This ensures that coulmn's position for 2d array is set 0 every time new line is to be read in readFile.txt a[z][i++]=x.next(); //assigns the values in line into 2d array a[z][i++] =x.next(); a[z][i++] =x.next(); a[z][i++] =x.next(); System.out.println("Enter number " + z + " Studet Task4 Mark"); //ask for stuent's number for task 4 a[z][i++] = input.next(); //user input request for task 4 marks System.out.println("Enter number " + z + " Studet Grade"); //ask for stuent's grade a[z][i++] = input.next(); //user input request for grades pw.println(a[z][0] + "\t\t" + a[z][1] + "" + a[z][2] + "" + a[z][3] + " " + a[z][4] + "" + a[z][5]); //write the stored data in 2d array into new.txt for each loop the row value will be fixed z++; //increase z's value by 1 } } pw.close(); //close new.txt file so that further changes cannot be done } catch(Exception e) { //catch any error in the code System.out.print("Could not find file"); //print this message if error found }
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
10OBJECT ORIENTED DESIGN AND PROGRAMMING } public void openFile() { //method for reading the new.txt file try { x=new Scanner (new File("new.txt")); //initialize the object x, a reference of class scanner with new.txt as parameter z=0; //initialize z's value to 0 so that from first row data can be read while(x.hasNext()) { //loop for reading the data from new.txt i=0; //initialize the i's value to 0 a[z][i++] =x.next(); //assigns the values in line into 2d array a[z][i++] =x.next(); a[z][i++] =x.next(); a[z][i++] =x.next(); a[z][i++] =x.next(); a[z][i++] =x.next(); System.out.printf("%s\t\t %s \t%s \t%s \t%s \t%s\n", a[z] [0], a[z][1], a[z][2], a[z][3], a[z][4], a[z][5]); //display the data stored in 2d array z++; //increase the z's value by 1 so that next row can be used } } catch(Exception e) {//catch any error in the code System.out.print("Could not find file"); //print this message if error found } } public void closeFile() { //method for closing the files x.close(); //statement for close the files so that further changes cannot be done to those files. }
11OBJECT ORIENTED DESIGN AND PROGRAMMING public static void main(String[] a) { main r = new main(); //initializing the readfile class with object named r r.execute(); //calling the method of copying data from readFile.txt and inserting into new.txt r.openFile(); //calling the method for displaying the data stored in new.txt r.closeFile(); //closing the readFile.txt } }
12OBJECT ORIENTED DESIGN AND PROGRAMMING Bibliography: Cooper, J.W., 2017.Design Pattarn Java Companion. Addison Wesley. Kitaya, H. and Inoue, U., 2016. An online automated scoring system for Java programming assignments.International Journal of Information and Education Technology,6(4), p.275. Sebesta, R.W., 2016.Concepts of programming languages. Tip,F.,2015.Infeasiblepathsinobject-orientedprograms.ScienceofComputer Programming,97, pp.91-97.