Write a class Battery that models a rechargeable battery.
totalCapacity: double
availableBattery: double;( this contains battery charge available)
String company;
· having no parameter – for setting values to zero or null.
· having two parameters for assigning values to both data members.
· Overload the above constructor and use this keyword to set the values of data members
· Provide getters and setters for data member(s).
· The method public void drain (double amount) drains the capacity of the battery by the given amount.
· The method public void charge (double amount) charges the battery by adding amount to availableBattery make sure it’s less than totalcapacity.
· A method toString to print object data.
1. Inside main, create 3 objects.
a. Set values of first object using constructor.
b. Take data from user and set the values for the 2 objects and display values.
2. Call all the above methods (drain, charge) and display updated values.
write a c++ program about this "Compute the final grade, the user will supply the recitation, exam, project, and attendance grade. Recitation is 15%, Exam is 35%, Project is 20% and Attendance is 30%. Final grade will be the sum of recitation, exam, project and attendance after getting the corresponding percentages."
Write a program/method to swap two neighboring numbers in an array when the first index is given
by CodeChum Admin
Do you believe in doppelgangers? Well they are very much possible with strings! Check if the two given strings are the same or not.
Instructions:
Instructions
Input
Two lines containing a string on each.
hello
helloOutput
The first line contains the two inputted strings separated by a \.
The second line contains a string result.
hello\hello
Equalby CodeChum Admin
They say that the one in first place is always greater than the one in the second and third place. Are they always right?
Instructions:
Instructions
Input
Three lines containing an integer on each.
3
2
1Output
The first line contains all the three inputted integers.
The second line contains a string which is the result.
3·2·1
YesWrite a C++ program which accepts amount in rupees as input (integer) within Range from
Rs. 100 to Rs. 100000 and then asks the user for particular currency note preference and display the total
number of currency notes of Rs. 500, 100, 50, 20, 10, 5, and 1. The user can be given a maximum of 200
notes of his preferred choice. (5 marks)
For example: when a user enters a number, Rs. 57477 and enters 50 notes as his preferred choice, the
results would be like this.
Currency Note : Number
500 : 94
100 : 4
50 : 200
20 : 3
10 : 1
5 : 1
1 : 2
Using switch-case statements only, write a C++ program that displays the following menu for
the food items available to take orders from the customer: (10 marks)
● Burgers
● Pizzas
● Sandwiches
When the user selects one of the options, a further submenu is displayed according to the chosen option.
The online food shop offers Crispy Chicken Burger (600 Rs.), Beef Burger (650 Rs.), and Fish Burger (700
Rs.) in the Burger category; Chicken tikka, Chicken Fajita and Four Seasons in the Pizza category; whereas
Club (300 Rs.), Chicken (325 Rs.), and Vegetables (315 Rs.) in the Sandwiches category. Prices of each food
item is also displayed to the user in the selected sub menu. The user will select the food item and quantity
of the item. In case of the Pizza items, the user can also select the size of pizzas (i.e. Small (850 Rs.),Medium (1200 Rs.), and Large (1600 Rs.)). The program outputs the total charges according to the chosen
options.
IFone, a cellular company, offersthe following three postpaid data packages to its customers.
(5+5 marks)
● Package A: For Rs. 100 per month, 1 GB data is provided. Additional data can be purchased for
Rs. 20 per 100 MB.
● Package B: For Rs. 200 per month, 2.5 GB data is provided. Additional data can be purchased
for Rs. 10 per 100 MB.
● Package C: For Rs. 1000 per month, unlimited access is provided.
Part A: Write a program that calculates a customer’s monthly bill. It should ask how many GBs the
customer has used in the month and which package the customer has subscribed for. It should then
display the total amount due.
Part-B: Modify the program in Part A so that it also displays how much money Package A customers
would save if they purchased packages B or C, and how much money Package B customers would save if
they purchased Package A or C. If there are no savings for a particular package, your program shall print
an appropriate message.
You are given a 9*9 grid as shown in the figure below. You can determine the color
of each square from the grid. The number of each square is also shown below. Write a C++ program for
this below given grid. The user is given two options to select from.
Part A: When the user selects 1st option, the user will enter number of square in this grid (any
number from 1-81). Your program will determine the color of the square.
Part B: When the user enters 2nd option, the user will enter two numbers from this grid. Your
program will determine if the two squares entered in this 9*9 grid have same color or not.
FAST-NUCES has expanded its operations to a great extent and it needs an automated
helpline system for its One Stop Student Center. In order to develop the system, FAST-NUCES has hired
the best programmers from its Islamabad campus. You are required to develop the following scenario for
the helpline system using switch-case construct in C++.
FAST-NUCES has five campuses at Islamabad, Lahore, Karachi, Peshawar, and Faisalabad in Pakistan.