Assignments
13 Slides56.60 KB
Assignments
Oops fundamentals Write java class for below example. List following. FYI : – Has refers to variable/fields/data of a class, – Does refers to methods of the class. 1) Product Has/instance variable : name, price, quantity Does/methods : buy, sell, negotiate 2) Car Has/instance variable : Does/methods : 3) Bank Has/instance variable : Does/methods : 4) Television Has/instance variable : Does/methods : 5) Fan Has/instance variable : Does/methods : 6) Tree Has/instance variable : Does/methods :
Variables All variables should have proper naming convention, java valid name , choose appropriate data types. Create variable create separate java programs and include relevant variables below in those programs. – to store Social security number. Just do the declaration. – To store Product Details. Declare and initialize on same line – To store last name. Declare and next line initialize. – To Store customer online status. Just Declare – To store value of pi . Just declare – To store customer phone number. Declare and initialize on same line – To store customer credit card details. Just declare – To store company contact info. Just Declare – To store height. . Declare and initialize on same line – To store employee salary. Declare and next line initialize. – To store add 2 cart details. Just Declare – To store payment details. Declare and next line initialize. – To store bank balance Just Declare – To store company name Declare and initialize on same line – To store bank account number Just Declare – To store shipping address Declare and initialize on same line
Data structure Refer java latest.xlsx for data structure creation process Design Data structure for Banking System. Create programs for each component of Banking System. Create complex data type programs if needed
Methods declaration and return statements Focus only on method declaration and include proper return statements. No logic required. – Create a method that can accept appropriate input for payment webpage and returns payment response. – Create a method that can process registration – Create a method that can accept product input and calculate total cart value Product program has quantity and price – Create a method that can calculate area of rectangle – Create a method that can calculate simple interest – Create a method that can process withdraw from bank account – Create a method that can process deposit from bank account – Create a method that can return electricity plan details if provided zip code as the input – Create a method that can return insurance detail if provided input as age. – Create a method that can return total amount if input provided is product price and discount percentage. – Create a method that can return user profile if provided customers userid and password as the input
Variable Scope Focus only on programs, variables and method. No logic required. – Car program has Vin and transportation type – Product program has quantity , name , price – Bank program does withdraw functionality that takes withdraw amount as input – Method that can calculate sum of 3 numbers and return sum – Calculating simple interest with P T R as input and return simple interest. Include local variable that can calculate PTR/100. – Create a method that can calculate area of square Accept side as input variable Use local variable to calculate area of square – Chase Bank Account program has bank name, customer names, balance. – Amazon program has method changePassword that takes userid and new password and confirms if password update was success or failure – Create a local variable age – Create a method that can calculate area of circle. Accept radius as input variable Use local variable to calculate area of circle
Operators LOGIC REQUIRED for all below programs using operators. – Bank program Has balance does withdraw functionality - include inputs , return outputs and logic. does deposit functionality - include inputs , return outputs and logic. – Method that can calculate sum of 3 numbers and return sum – Calculating simple interest with P T R as input and return simple interest. Include local variable that can calculate PTR/100. – Create a method that can calculate area of square Accept side as input variable Use local variable to calculate area of square – Create a method that can calculate area of circle. Accept radius as input variable Use local variable to calculate area of circle – Create a method that can calculate area of rectangle – Create a method that can return total final amount , if input provided is product price and discount percentage.
Operators LOGIC REQUIRED for all below programs using operators. – Create login program (has-a)Declare global variable registerUserid and register password Create login method that takes loginUserid and login password Print if login is success or failed – Create website program (has-a)Declare global variable existingUserid Create register method that takes new registeration userid and password Based on If exsting userid matches new registeration id then registration fails else registeration method print success or failure. – Create bank program (has-a)Declare global variable bank money Create applyLoan method takes loan amount input. If customer requestsing loan amount is less than bank available money then print loan approved or denied. – Create amazon program (has-a)Declare global variable stock Create order method. Based on If order quantity is less than stock print order approved or cancelled. – Create currency program Take dollar as input and return the UK pound equivalent
Control Flows – Write a method that takes number as input using for loop Print 1 , 2,3 till the number provided as input – Write a method to print “customer care” if input to method is 1 else print “other help”. – Write a program that has-a registered phone, userid, password Create a method to retrieve userid. That will take input as phone and if phone matches registered phone return userid. Create a method to retrieve password. That will take input as userid and if userid matches registered userid return password. – Write a shopping program that has-a balance, product price Create a checkout method that takes orderquantity as input. Calculate total cart price based on quantity input and product price. If total cart prices is less than balance than return success else return failure – Write a method that takes number as input using while loop Print multiple of 1 to 10 for this input – Write a method to print menu items (use Switch case) Display the price for item selected 1 – Pizza 2 – Pasta Default – salad
Constructor – – – – Write a program for products Product has-a name,quantity,price User can construct product – By name – By name and price Write a program for UserProfile UserProfile has-a userid,password,email,phone Can construct Userprofile – By userid and password – By email and password – By phone and password Write a program for Payment Payment has creditCardNumber, creditcardExpiry,creditCardSecCode,paypalUsserid,paypalPassword Can construct payment – By creditCardNumber, creditcardExpiry,creditCardSecCode – By paypalUsserid,paypalPassword Write a program for MoneyTransfer MoneyTransfer has-a receiverAccountNumber, ReceiverPhone,ReceiverEmail,Amount Can construct MoneyTransfer – By receiverAccountNumber and amount – By receiverPhoen and amount – By ReceiverEmail and amount
Inheritance- super/parent and sub/child class – – – – Write a program for calcualator Method add that takes 2 int input and returns int Method sub that takes 2 int input and returns int Method mul that takes 2 int input and returns int Method div that takes 2 int input and returns int Write a program for advancedCalculator that inherits from Calculator Method square takes 1 int input and returns int area of square. use multiply from parent Method rectangle takes 2 int input and returns int area of rectangle use multiply method from parent Write a program for Cart that inherits from calculator Method calculateCart that takes 2 int input product price and quantity and returns total value of cart. Use parent method multiply.
Inheritance- super/parent and sub/child class – Write a program for below inheritance scenario Person employee tester Person employee developer – Person » Has name, age » Does talk, walk ( just sysout in this method is fine) – employee » Has name, age, salary » Does talk, walk ( just sysout in this method is fine) – Tester » Has name, age, salary, jobTitle » Does talk, walk, work ( just sysout in this method is fine) – Developer » Has name, age, salary, jobTitle » Does talk, walk, work ( just sysout in this method is fine)
Inheritance- Interface – – – – – – Write a program for ILogin interface Create abstract methods. – Register method that return register is success or failure, and takes input userid and password and email – Login method that return login is success or failure, and takes input userid and password – Change password method that return change is success or failure, and takes input userid and newpassword Write a program Login class that implements Ilogin Write the code for all abstract methods (just sysout is fine) ************************************************************** Write a program for INotification interface Create abstract methods. – sendNotification method that return notification is success or failure, and takes input message Write a program Email class that implements INotification Write the code for all abstract methods (just sysout is fine) Write a program Text class that implements INotification Write the code for all abstract methods (just sysout is fine) Write a program Phone class that implements INotification Write the code for all abstract methods (just sysout is fine)