Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ visual studio Gift Card Tracker Target Gift Card Tracker 1- Add Gift Card 2-

ID: 3756838 • Letter: C

Question

C++ visual studio

Gift Card Tracker Target Gift Card Tracker 1- Add Gift Card 2- Remove Gift Card 3- Report e- Exit Choice: 1 Code: 5e08e Your task is to write a simple app that allows me to keep track of my gift cards from Target store. Here are the features of this program: Feature #1 (60 points): Add a Gift Card: I should be able to add a gift card to the program. I will enter the gift card code which is a number. The value of the Gift Card Tracker gift card (the amount of money in it) can be determined by this number 1- Add Gift Card 3 Regovt Gift Card f the card code is above (or equal) 50000, then it has $5 value in it. The 3- Report 0- Exit Choice: 1 Code: 32500 cards with code at 40000s (40000 to 49999) has $4 in it. The cards with code at 30000s (30000 to 39999) has $3 and so on all the way down to 10000s (10000 to 19999) has $1 in it. Any code less than 10000 is an invalid code Gift Card Trackernumber-let the user know with a message. 1- Add Gift Card 2-Remove Gift Card 3- Report e- Exit Choice: 2 Code: 50600e Feature #2 (50 points): Remove a Gift Card: Sometimes, I may give my gift card away or spend it, in which case, I need to be able to remove the card from the system. I will enter the card code and you will determine what value the card has from the code (just like in feature #1) and remove from the system. Gift Card Tracker 1- Add Gift CardTechnically, if I never enter a 5$ card and I ask the program to remove a $5 2- Renove Gift Card 3- Report 0- Exit Choice: 1 Code: 12565 card, it will be a problem. But you need not worry about this case. I will make sure at my end that I never try to remove a card that is not already in the system Feature #3 (50 points): Report: I should be able to get a detailed report from Gift Card Tracker the program displaying how many of each type of cards ($1, $2, $3, $4 or $5 ev cf ard cards) I have and the total number of cards and as well as the average value 1- Add Gift Card of cards. This report changes as I add/remove cards from the system. 3- Report 0- Exit Choice: 1 Code: 1254 Invalid code! Feature #0 (20 points): I should be able to exit out of the program when I am done. Gift Card Tracker User will pick one of the 4 features- if user makes an invalid choice (enters a number other than these 4 options), let the user know that it is an invalid entry. (20 points) Add Gift Card 2- Remove Gift Card 3- Report 0- Exit Choice:3 You have: For more information, refer to the sample screenshot on the left. Please make your program is as close as possible to this example 0 $5-card

Explanation / Answer

/*The array cardData stores the number of cards of each type.
Index 0 of cardData stores the count of cards 10000 to 19999,
index 2 stores count for card codes 20000 to 29999, and so on.
For adding and deleting card, the code is divided by 10000.
From this value of code the index of cardData, whose value will be increased or decreased is determined.
*/

#include <iostream>
using namespace std;

int main(){
   //choice stores the user choice during execution
   //repeat is used to control the continuation of the user interaction
   //code is used to store the card code entered by the user
   //count stores the total count of cards
   //cardData keeps track of the count of each type of card;
   int i,choice,repeat=1,code,count,cardData[5];
   //sum stores the total worth of cards
   float sum;
  
   for(i=0;i<5;i++)
       cardData[i]=0;   //Initially both the count for each type of card is set to zero
      
   while(repeat){
       //Display the menu
       cout<<" Gift Card Tracker ================== 1- Add Gift Card 2- Remove Gift Card 3- Report 0- Exit Choice: ";
       cin>>choice;
       switch(choice){
           case 1:
               cout<<"Code: ";
               cin>>code;
               code/=10000;
               //code less than 10000 is invalid.
               if(code<1)
               cout<<"Invalid Code!";
               //code greater than 50000 has value of $5 hence value of index 4 is increased
               else if(code>5)
               cardData[4]++;
               //index corresponding to code is increased
               else
               cardData[code-1]++;
               break;
           case 2:
               cout<<"Code: ";
               cin>>code;
               code/=10000;
               //code less than 10000 is invalid.
               if(code<1)
               cout<<"Invalid Code!";
               //code greater than 50000 has value of $5 hence value of index 4 is decreased
               else if(code>5)
               cardData[4]--;
               //index corresponding to code is decreased
               else
               cardData[code-1]--;
               break;
           case 3:
               cout<<"You have: ";
               for(i=0,sum=0,count=0;i<5;i++){
                   sum+=(i+1)*((cardData[i]>0)?cardData[i]:0);
                   count+=(cardData[i]>0)?cardData[i]:0;
                   cout<<"    "<<cardData[i]<<" $"<<i+1<<"-card ";
               }
               cout<<"Total Cards: "<<count<<" Average value: $"<<sum/count;
              
               break;
           case 0:
               //set repeat to zero to make the repeat condition false and breakout of the loop.
               repeat=0;
               break;
           default:
               cout<<"Invalid Choice!";
       }
   }   
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote