Question Details

[solution] » I need help with Change Medal Count and removeCountry

Brief item decscription

Step-by-step solution file


Item details:

I need help with Change Medal Count and removeCountry
More:

I need help with Change Medal Count and removeCountry


//

 

//

 

//

 

//

 

//

 

//

 


 

Assignment #1

 

Name:

 

ASU Email Address:

 

Description: This program displays a menu of choices to a user

 

and performs the chosen task. It will keep asking a user to

 

enter the next choice until the choice of 'Q' (Quit) is entered.

 


 

#include

 

#include

 

#include

 

#include

 


 

"stdafx.h"

 

<iostream>

 

<string>

 

"LinkedList.h"

 


 

using namespace std;

 

void printMenu();

 

int main()

 

{

 

// local variables, can be accessed anywhere from the main method

 

char input1 = 'Z';

 

string inputInfo;

 

string countryName, medalType;

 

int gold, silver, bronze, count;

 

string line;

 

bool success = false;

 

// instantiate a Linked List object

 

LinkedList * list1 = new LinkedList();

 

printMenu();

 

do

 

{

 


 

// will ask for user input

 

cout << "

 

What action would you like to perform?

 

";

 

cin.get(input1);

 

input1 = toupper(input1);

 

cin.ignore(20, '

 

'); //flush the buffer

 

// matches one of the case statement

 

switch (input1)

 

{

 

case 'A':

 

//Add Country

 

cout << "Please enter some country information:

 

";

 

cout << "Enter a country name:

 

";

 

getline(cin, countryName);

 

cout << "Enter its number of gold medals:

 

";

 

cin >> gold;

 

cin.ignore(20, '

 

'); //flush the buffer

 

cout << "Enter its number of silver medals:

 

";

 

cin >> silver;

 

cin.ignore(20, '

 

'); //flush the buffer

 

cout << "Enter its number of bronze medals:

 

";

 

cin >> bronze;

 

cin.ignore(20, '

 

'); //flush the buffer

 

success = list1->addCountry(countryName, gold, silver,

 


 

bronze);

 

if (success == true)

 

cout << "The country " << countryName << " added

 

";

 


 

else

 


 

cout << "The country " << countryName << " not added

 

";

 

break;

 

case 'D':

 

//Display Countries

 

list1->printList();

 

break;

 

case 'M': //Change Medal Count

 

cout << "Please enter a country to change its medal count:

 

";

 

getline(cin, countryName);

 

cout << "Please enter a medal type (gold, silver, or

 

bronze):

 

";

 

getline(cin, medalType);

 

cout << "Enter its new medal count:

 

";

 

cin >> count;

 

cin.ignore(20, '

 

'); //flush the buffer

 

success = list1->changeMedalCount(countryName, medalType,

 


 

count);

 


 

if (success == true)

 

cout << "The country " << countryName << " updated

 

";

 

else

 

cout << "The country " << countryName << " does not

 

exist

 

";

 


 

break;

 

case 'Q':

 

//Quit

 

delete list1;

 

break;

 

case 'R': //Remove Country

 

cout << "Please enter a country to remove:

 

";

 

getline(cin, countryName);

 

success = list1->removeCountry(countryName);

 

if (success == true)

 

cout << "The country " << countryName << " removed

 

";

 

else

 

cout << "The country " << countryName << " does not

 


 

exist

 

";

 


 

break;

 

case '?':

 

//Display Menu

 

printMenu();

 

break;

 

default:

 

cout << "Unknown action

 

";

 

break;

 

}

 


 

} while (input1 != 'Q');

 

}

 


 

return 0;

 


 

/** The method printMenu displays the menu to a user**/

 

void printMenu()

 

{

 

cout << "Choice Action

 

";

 

cout << "------ ------

 

";

 

cout << "A Add Country

 

";

 

cout << "D Display Countries

 

";

 

cout << "M Change Medal Count

 

";

 

cout << "Q Quit

 

";

 

cout << "R Remove Country

 

";

 

cout << "? Display Help

 

";

 

}

 


 

 







About this question:
STATUS
Answered
QUALITY
Approved
ANSWER RATING

This question was answered on: Feb 21, 2020

PRICE: $24

Solution~000636603.zip (18.37 KB)

Buy this answer for only: $24

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy (Deadline assured. Flexible pricing. TurnItIn Report provided)

Pay using PayPal (No PayPal account Required) or your credit card. All your purchases are securely protected by PayPal.
SiteLock

Need a similar solution fast, written anew from scratch? Place your own custom order

We have top-notch tutors who can help you with your essay at a reasonable cost and then you can simply use that essay as a template to build your own arguments. This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student. New solution orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

Order Now