HBL Bank requires account management software. The branch manager met with the software engineers and
discussed the details/requirements. According to him, the bank needs to store account title (name), account
number, account type and balance for each account entry. You can deposit and withdraw amount. You are required
to provide a library that can be utilized in the management system.
Write a program that creates a class called Pizza. The data members of the class are size (inches), topping, price (PKR)
and thickness (cm). Through the use of a constructor, initialize the class object and assign default values to data
members. Determine whatis public and private in the class. Add setter and getter method for each attribute. Write a
global function “Display” (should not be member of class) that is able to print all information of a single Pizza object
on screen. In main() function, make an array of 5 Pizza objects with different values and print information of all
objects on screen thru Display function.
1. Consider the following program, what is the output? (5 marks)
class overload
{
int x;
double y;
void add(int a , int b)
{ x = a + b; }
void add(double c , double d)
{ y = c + d; } overload()
{ this.x = 0;
this.y = 0;
}
} class Overload_methods
{ public static void main(String args[])
{
overload obj = new overload();
int a = 2; double b = 3.2;
obj.add(a, a);
obj.add(b, b);
System.out.println(obj.x + " " + obj.y);
1.i)Create a class to hold all student attribute (name,reg number, course , gender and age) a read details method which interact with a user and read students details write details method to print write student details.
ii) create a main function which will prompt a user to enter student details call function read details and write details from a class above to read and write student detail respectively
Groupings
by CodeChum Admin
Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.
Instructions:
Create a variable that accepts a positive odd integer.
Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
Reverse the order of the list. Then, print out the list's new order in this manner:
[first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.
Input
The first line contains an odd positive integer.
The next lines contains an integer.
5
1
3
4
5
2
Output
A line containing a list.
[2,5]-[4]-[3,1]
write a program to store the data of mobile shop in a file with appropriate data members and member functions. use read and writes method to perform the file operations. read only the price and model value of mobile from file.
The GCD
by CodeChum Admin
The greatest common divisor, also known as GCD, is the greatest number that will, without a remainder, fully divide a pair of integers.
Now, I want you to make a program that will accept two integers and with the use of loops, print out their GCD. Make good use of conditional statements as well.
Off you go!
Input
A line containing two integers separated by a space.
6·9
Output
A line containing an integer.
3
Arraying 102
by CodeChum Admin
We've already made arraying/listing the easy way, but how about arraying/listing and printing the list in reverse order?
Make a program that will input an integer and then using loops, add items on an array/list one by one for the same number of times as that of the first inputted integer. Then, print out the array/list in reverse order, that is, starting from the last item on the array/list down to the first one, each in separated lines.
Input
The first line contains the size of the array/list.
The next lines contains the items of the array/list (integers).
5
1
64
32
2
11
Output
Multiple lines containing integers.
11
2
32
64
1
only 1 testcase is getting fail where its loged in console as NAN. The formula to calculate the final value with appreciation is, finalValue = principal * (1 + time * appreciation / 100).
Final Value with Appreciation:
Given principal amount
principal as an input, time period in years time and appreciation percentage apprPercentage as optional inputs, write a JS function to return the final value finalValue with the given appreciation percentage and time period. The default values for time and apprPercentage are 2 and 5 respectively.
Input
1)2000
Expected
2200
Define a class ABC. Derive two classes BBC and KBC from ABC. All the classes contains same member function name as display(). The base class pointer always holds the derived class objects.
a) Write a program such that base class pointer or reference will always access/call the base version of the members available in derived class, do not have any access to the derived class members.
b) Write a program such that base class pointer or reference will always access/call the derived version of the members available in derived class, do not have any access to the base class members.
Write down the concepts used for bit a) and b) separately.