Write a program in C++ to open and read the contents of the Text1.txt using the file stream class.
Close the file and again open to update the contents of given file Text1.txt.
Text1.txt : I am enjoying learning OOPS concepts
After update
Text1.txt: I am enjoying learning OOPS concepts
Now learnt C++; Java is my next target.
Write a program in C++ to accept date in dd:mm:yyyy format. Store these values in MyDate Class
with members as day, month and year. Convert this date into one variable “Duration” of the current
years. This duration means number of days passed in the current year since Jan 1.
Hint :Use type conversion method from class type to basic type conversions.
Note: consider days in February as 28 for all years.
Output expected:
Enter Date : 05:04:2021
No of days since Jan 1 of the current year : 90
Problem 2
•Develop a program working as a soda vending machine. The program should show the product menu with price and take user input for product number, quantity and pay amount. The output should show the total sale price including tax and the change.
Input
1.Product Number
2.Product Quantity
3.Payment Amount
Process
1.Show menu
2.Calculate purchase
3.Take payment
4.Calculate tax
5.Calculate Total purchase
6.Calculate Change
Output
1.Total Purcahse
2.Tax (6% of Total Purcahse )
3.Change
**************Vending Machine ****************
1. Coke $1.25
2. Pepsi $1.00
3. Water $2.00
4. Coffee $1.50
5. Exit Menu
Enter your Choice:1
How many do you want?1
How much is your payment?2
Tax Amount : $0.075
Total Purchase :$1.325
Change : $0.675
Complete a program that allows the user to choose addition or subtraction operations on two numbers entered from the keyboard.
Input
1.Choice of operation
2.First number
3.Second number
Process
If choose to perform operation, add two numbers; otherwise, subtract two numbers
Output
Result of operation
Sample Output
Enter your choice, 1 for Addition, 2 for subtraction:
Enter first number
Enter second number
The result of the operation is:
Write a program class name BaraBitKaar
BaraBitKaar Add(BaraBitKaar b);
When this function called in main() like following example:
BaraBitKaar p( "01111111111100000000000001111111101010100101111111111111111111111111111111111111111111111111111111111011111101110101111101011011");
BaraBitKaar q( "00111111111100000000000001111111101010100101111111111111111111111111111111111111111111111111111111111011111101110101111101011011");
BaraBitKaar r;
r = p.Add(q); //this is how Add is supposed to be used to add p and q. Notice r receives the return which is of type BaraBitKaar.
r.PrintBinary(); //
Make class BaraBitkaar as described in lecture to represent 16Byte or 128bit numbers. Make three functions as BitKaar of A8 i.e. PrintBinary(), PrintDecimal(), and PrintHexadecimal() respectively. Also make a member function SetValue(char * valuestring), that takes as parameter a 128 character string for example "11111111111100000000000001111111101010100101111111111111111111111111111111111111111111111111111111111011111101110101111101011011" containing the binary representation and sets the value of private members accordingly. Remember there is a member char var[16] which contains the binary value.work program output bitwise.
Make a program that will compute the prelim, midterm, final grades of the students. The program will input grades for quiz, recitation, project, and exam rating. The class standing, the class average and the prelim, midterm and final grades will be computed and displayed automatically. Display also the grade equivalent and if the grade of the student is greater than 75 then the remark will be “Passed” otherwise “Failed” Use any selection and repetition structures. Use these formulas:
PRELIM:
CS = (Q + R) / 2
PROJECT = P* 40%
LECTURE = ((2 * CS + ER) / 3) * 60%
PG = PROJECT + LECTURE
MIDTERM:
CSM = (QM + RM) / 2
MPROJECT = PM * 40%
MLECTURE = (2*CSM + MER) / 3 * 60%
CAM = MPROJECT + MLECTURE
MG = (2 * CAM + PG) / 3
FINALS:
CSF = (QF + RF) / 2
FPROJECT = PF * 40%
FLECTURE = ((2 * CSF + PER) / 3 * 60%
CAF = FPROJECT + FLECTURE
FG = (2*CAF+MG) / 3
Create a class: “Palindrome” with private data members: upper_limit (int), lower_limit (int) and parameterized constructor, which initializes the values of both data members. Apart from initialization, this constructor also displays the count of palindrome numbers from upper_limit to lower_limit. [Example: upper_limit:50, lower_limit:10, count of palindrome numbers is: 4(11 , 22, 33 and 44), also make sure the value of upper_limit should be greater than lower_limit].
There are following two major issues associated with cpp programs:
Suggest a solution and elaborate the same with the help of suitable examples.
Create a class Employee with the data members such as name, id and total salary. Create a file as “Employee_Data” as binary file and write the information of four employees to that file. Open that file in reading mode and only display the record of 2nd and 3rd employees