A1-OOP- Spring-2021-Nadir Ali Kazmi 02-235182-022 PDF

Title A1-OOP- Spring-2021-Nadir Ali Kazmi 02-235182-022
Author Nadir Ali
Course Object Oriented Programming
Institution Bahria University
Pages 9
File Size 521.3 KB
File Type PDF
Total Downloads 556
Total Views 1,022

Summary

Bahria University Karachi Campus Semester 02 (SPRING 2021)ASSIGNMENT 01Marks: 5NAME: NADIR ALI KAZMICLASS: BS IT 2 - AREG. NO. 46021COURSE: Object oriented programmingCOURSE CODE: CSC- 210Read Carefully: - The deadline for this assignment is before Thursday 04/04/2021.WARNING : This is an individual...


Description

Department of Computer Science Bahria University Karachi Campus

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

ASSIGNMENT 01 Marks: 5

NAME: NADIR ALI KAZMI CLASS: BS IT 2 - A REG. NO. 46021 COURSE: Object oriented programming COURSE CODE: CSC- 210 Read Carefully: • The deadline for this assignment is before Thursday 04/04/2021. WARNING: This is an individual assignment; you must solve it by yourself. Any form of plagiarism will result in receiving zero in the assignment. WARNING: Late submission will not be accepted. Any assignment submitted after the cutof time will receive zero. •

Submit SOFTCOPY on LMS in pdf format



Answer should be written in given space. If there is any programming related tasks then paste the code properly along with the screenshots of output.

Department of Computer Science Bahria University Karachi Campus

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

Q1. Engr. Sarim is supposed to computerize food management system for Pizzoa, a new food venture opened in Karachi. Sarim is working as a senior software developer in a renowned organization. Requirements of Pizzoa for a system are as follows which are collected:  A system should be menu driven, at the time of execution program should display following menu. o Press 1 for Display menu. o Press 2 for add item in menu. o Press 3 to delete item from menu o Press 4 to exit. CODING: 1. Create a class for pizzoa , add required attributes where one attribute is Manager_name. Write methods for add item, delete item, and display menu. Hint: you can use array list for menu items. 2. Create application class where you have to create an object of pizzoa class. 3. Assign manager name as your name from application class using object reference. 4. Write a code to display above mentioned menu in application class. 5. Take user input for desired choice of button and using conditional statements (ifelse/switch case) call appropriate methods of pizzoa class. 6. On pressing 4 application program should stop running. Hint: use exit() REQUIRED OUTPUT 1. Run the program and add 10 food items of your choice in menu, and then display menu. 2. Delete any 2 items of your choice and then display menu.

Department of Computer Science Bahria University Karachi Campus

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

import java.util.Scanner; // Import the Scanner class import java.util.Arrays; import java.util.ArrayList; public class pizzoa{ static ArrayList menu = new ArrayList(); String Manager_name; static int y = 1; static Scanner inp; public ArrayList add(){ Scanner additem = new Scanner (System.in); System.out.println("Enter Item to Add: "); menu.add(additem.nextLine()); return menu; } public ArrayList delete(){ Scanner delitem = new Scanner (System.in); System.out.println("Enter Item to Delete: "); int indexx = menu.indexOf(delitem.nextLine()); menu.remove(indexx); return menu; } public void display(){ for (String element: menu) { System.out.println(element); } } public void back(){ System.exit(0); } public static void main(String []args){ while (y == 1){ application.main(); System.out.println("Do you want to continue y == 1/n == 0? "); y = inp.nextInt(); } System.exit(0); } }

Department of Computer Science Bahria University Karachi Campus

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

class application{ static int option; public static void Selection(){ System.out.println ( "1) Display Menu \n2) Add Item \n3) Delete Item \n4) Exit \n" ); } public static void main(){ pizzoa myobj = new pizzoa(); myobj.Manager_name = "NadirAliKazmi"; Selection(); myobj.inp = new Scanner ( System.in ); System.out.println("Enter Your Option: "); option = myobj.inp.nextInt(); System.out.println(option);

switch (option){ case 1: System.out.println ("Selected Display Menu \n"); myobj.display(); break; case 2: System.out.println ("Selected Add Item \n"); myobj.add(); break; case 3: System.out.println ("Selected Delete Item \n"); myobj.delete(); break; case 4: System.out.println ("Selected Exit\n"); myobj.back(); break; default: System.err.println ("Invalid Option \n"); break; } }

Department of Computer Science Bahria University Karachi Campus

}

ADD ITEMS

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

Department of Computer Science Bahria University Karachi Campus

DELETE ITEMS

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

Department of Computer Science Bahria University Karachi Campus

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

Q2. Consider that you need to develop a software for PWF School. Requirements from client (PWF school representative) is to have a software that saves the information of all the students and have the facility of fees payment as well. Student’s name, class, address, ID and contact are the basic components of information that needs to be stored in a system. User will be able to enter all these information in a system, and also can enter the fees and see the updated status as well. Fee structure is given below for all the classes. Class I,II, III IV, V VI,VII,VIII IX, X

Monthly Fees 2500/3000/3500/5000/-

1. Construct a class for Student, mention all its attribute as private. 2. Write getter setter methods to set and get the values of all the attributes. 3. Write the code for parameterized and non-parameterized constructors as well for the student class. 4. Develop a method of Feepayment, which ask from user to enter fee amount and class and matches from the data given in above table if user paid correct amount or not. If excess amount is paid then a message will be shown that this amount is returned to the user and if less amount is paid then message will be shown that “Enter full amount”. 5. Develop a method of Fee status as well. Which shows the Fee status as paid or not paid. 6. Develop a method Showinfo( ) that shows the student name,class, ID and fee status. 7. Develop an application class and create 5 objects of student. Enter data for all 5 students and pay their fees as well (use various amount inputs), and call showinfo() method for all 5 students.

class Student { private int stuID; private String stuName; private int stuAge;

Department of Computer Science Bahria University Karachi Campus

Student() { //Default constructor stuID = 100; stuName = "New Student"; stuAge = 18; } Student(int num1, String str, int num2) { //Parameterized constructor stuID = num1; stuName = str; stuAge = num2; } //Getter and setter methods public int getStuID() { return stuID; } public void setStuID(int stuID) { this.stuID = stuID; } public String getStuName() { return stuName; } public void setStuName(String stuName) { this.stuName = stuName; } public int getStuAge() {

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

Department of Computer Science Bahria University Karachi Campus

CSC-210:Object-Oriented Programming Semester 02 (SPRING 2021)

return stuAge; } public void setStuAge(int stuAge) { this.stuAge = stuAge; }

public static void main(String args[]) { //This object creation would call the default constructor Student myobj = new Student(); System.out.println("Student Name is: "+myobj.getStuName()); System.out.println("Student Age is: "+myobj.getStuAge()); System.out.println("Student ID is: "+myobj.getStuID());

/*This object creation would call the parameterized * constructor Student(int, String, int)*/ Student myobj2 = new Student(555, "Ali", 25); System.out.println("Student Name is: "+myobj2.getStuName()); System.out.println("Student Age is: "+myobj2.getStuAge()); System.out.println("Student ID is: "+myobj2.getStuID()); } }...


Similar Free PDFs