#include #include "HPVISACard.cpp" #include using namespace std; int main() { // Declare variables string type; double amount; int rewardPercentage,choice; // print menu cout<<"Menu"<<"\n1.VISA Card"<<"\n2.HPVISA Card"<>choice; // conditionally execute based on user choice switch(choice){ // case 1 case 1:{ // ask user to enter transaction type cout<<"Enter the transaction type"<>type; // ask user to enter transaction amount cout<<"Enter the transaction amount"<>amount; // ask user to enter reward points cout<<"Enter the reward points"<>rewardPercentage; // create VISACard class object using parameterized constructor VISACard v1(type,amount,rewardPercentage); // print card details by calling suitable methods cout<<"Card details:"<>type; // ask user to enter amount cout<<"Enter the transaction amount"<>amount; // create a object of class HPVISACard HPVISACard hv1(type,amount); // print card details by calling suitable methods cout<<"Card details:"< #include #include "VISACard.cpp" using namespace std; class HPVISACard :public VISACard{ public: void computeRewardPoints() { // declare RewardPoints to store points float RewardPoints; // if type == Fueal if(getType()=="Fuel"){ // calculate 3% amount and add 10 extra points RewardPoints = (amount * (3/100.0))+10; } // else calculate 3% of amount else{ RewardPoints = (amount * (3/100.0)); } // finally print Reward Points cout<<"Reward point:"< #include using namespace std; class VISACard { // protected members of class protected: string type; double amount; // private members of class private: int rewardPercentage; // public members of class public: void computeRewardPoints() { // calculate Reward points based on reward percentage float RewardPoints = amount*(getRewardPercentage()/100.0); // finally print reward points cout<<"Reward point:"<type = type; } void setAmount (double amount){ this->amount = amount; } void setRewardPercentage (int rewardPercentage){ this->rewardPercentage = rewardPercentage; } // getters int getRewardPercentage(){ return rewardPercentage; } string getType(){ return type; } double getAmount(){ return amount; } }; YOU HAVE TO FIND WHY THE OUTPUT IS NOT MATCHING AND MODIFY MY CODE ACCORDING TO THAT.
QUESTION AND COLLEGE COMPILER OUTPUT ATTACHED IN IMAGE . PLEASE SEE
AND MY SOLUTION TO THE PROBLEM IS GIVEN BELOW.
------------MY SOLUTION----------
MAIN.CPP
#include <iostream> #include "HPVISACard.cpp" using namespace std; int main() { // ask user to enter his choice // ask user to enter transaction amount // ask user to enter reward points // print card details by calling suitable methods // ask user to enter amount // create a object of class HPVISACard // print card details by calling suitable methods |
HPVISCACard.cpp
#include <iostream> class HPVISACard :public VISACard{ // if type == Fueal // else calculate 3% of amount // finally print Reward Points // calling super class constructor |
viscard.cpp
#include <iostream> class VISACard { // private members of class // public members of class // finally print reward points public: // constructor with 2 params // setters // getters |
YOU HAVE TO FIND WHY THE OUTPUT IS NOT MATCHING AND MODIFY MY CODE ACCORDING TO THAT.
![COMPILER OUPTPUT MISMATCH
Test Script - Main
S.No
Test
Expected
Obtained
Differences
Test Script - Main
Menu
Menu
Menu
Input: 1
1.VISA Card
1.VISA Card
1.VISA Card
Shopping
2.HPVISA Card
2.HPVISA Card
2.HPVISA Card
5000
Enter the choice
Enter the choice
Enter the choice
Enter the transaction type
Enter the transaction type
Enter the transaction type
Enter the transaction amount
Enter the transaction amount
Enter the transaction amount
Enter the reward points
Enter the reward points
Enter the reward points
Card details:
Type: Shepping
Amount: 5000
Reward point: 100.0
Card details:
Reward point:100.0
Type: Shopping
Amount: 5000
Reward point: 100.0
Test Script - Main
Menu
Menu
Menu
Input: 2
1.VISA Card
1.VISA Card
1.VISA Card
Fuel
2.HPVISA Card
2.HPVISA Card
2.HPVISA Card
650
Enter the choice
Enter the choice
Enter the choice
Enter the transaction type
Enter the transaction type
Enter the transaction type
Enter the transaction amount
Enter the transaction amount
Enter the transaction amount
Card details:
Fype: Fuet
Amount: 650
Reward point: 29.5
Card details:
Reward point:29.5
Туре: Fuel
Amount: 650
Reward point: 29.5
3
Test Script - Main
Menu
Menu
Input: 3
1.VISA Card
1.VISA Card
2.HPVISA Card
2.HPVISA Card
Enter the choice
Enter the choice
Invalid input
Invalid input
2.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F8deb4dee-94e2-4016-aac5-3aeff4bdb06f%2F14eb6dca-6fc2-4f34-b58f-1feb237661c8%2Fz3sippv_processed.png&w=3840&q=75)
![ABC Bank announced a new scheme of reward points for a transaction using an ATM card. Each
transaction using the normal card will be provided by giving a reward percentage of the transaction
amount as a reward point. If a transaction is made using a premium card and it is for fuel expenses,
additional 10 points will be rewarded.
Write a program to calculate the total reward points.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class
names, member variable names, and function names should be the same as specified in the problem
statement.
A class VISACard has the following attributes.
Access Specifiers
Data type
string
double
int
Variable
protected
protected
private
type
lamount
rewardPercentage
Include the following method in VISACard class.
Method
Description
In this method, calculate and display the reward points
based on rewardPercentage in amount
public void ComputeRewardPoints()
Formula:
Reward points = amount * (rewardPercentage / 1o0)
A derived class HPVISACard derived from VISACard class and overrides the following method.
Method
Description
In this method, calculate the reward point.
3% of the amount will be reward points.
If the transaction type is fuel, add 10 points to calculate reward points.
public void ComputeRewardPoints()
Formula:
Transaction type (Fuel): Reward points = (amount * (3/100))+ 10
Type other than fuel: Reward points = amount * (3/ 100)
In the Main method, obtain input from the user.
Create VISACard or HPVISACard objects and invoke display methods to display the details.
Card type will be either 'VISA card' or 'HPVISA card'. Otherwise, display 'Invalid input'
Calculate the reward points corresponding to the card type and transaction type and print the reward
points(upto two precision).
Input and Output Format:
Refer sample input and output for formatting specifications.
All text in bold corresponds to the input and the rest corresponds to output.
Sample Input and Output 1:
Menu
1.VISA Card
2.HPVISA Card
Enter the choice
1
Enter the transaction type
Shopping
Enter the transaction amount
5000
Enter the reward points
Card details:
Type: Shopping
Amount: 5000
Reward point: 100.0
Sample Input and Output 2:
Menu
1.VISA Card
2.HPVISA Card
Enter the choice
2
Enter the transaction type
Fuel
Enter the transaction amount
650
Card details:
Туре: Fuel
Amount: 650
Reward point: 29.5
Sample Input and Output 3:
Menu
1.VISA Card
2.HPVISA Card
Enter the choice
3
Invalid input](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F8deb4dee-94e2-4016-aac5-3aeff4bdb06f%2F14eb6dca-6fc2-4f34-b58f-1feb237661c8%2Fgjcl52m_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 10 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)