C++

I am trying to create a program that displays shipping charges for two region codes. The region code has to have exactly 3 characters (the letter A or B followed by two numbers). Display a message if invalid region code is entered. use a sentinel value to exit program. shipping for region A is $25 and region B is $30

Here is what I have so far.
<code>
#include <iostream>
#include <string>
using namespace std;

int main()
{
string regionCode = "";

cout << "Please enter region code (-1 to exit): ";
getline(cin, regionCode);

while (regionCode != "-1")

if (regionCode.find('A', 0))
{
cout << "Shipping cost is $25" << endl;
}

else if (regionCode.find('B', 0));
{
cout << "Shipping cost is $30" << endl;
}
else if
{
cout << "Please enter a valid region code" << endl;
} //end if

cout << "Please enter region code (-1 to exit): ";
getline(cin, regionCode);

system("PAUSE");
return 0;
} //end of main function
</code>

  1. 👍
  2. 👎
  3. 👁
  1. so, have you compiled and run it?
    does it do the job?

    1. 👍
    2. 👎
  2. It won't compile because it's saying the second "else if" isn't valid. I have tried changing things around and the best I can get is when I enter a value starting with"A" it returns nothing and a value starting with "B" returns and endless loop of $25, but it should be $30 and then wait for the user to enter a key to exit

    1. 👍
    2. 👎

Respond to this Question

First Name

Your Response

Similar Questions

  1. computer programming

    Design the logic for a program that allows a user to enter any amount of numbers up to 10 or until a sentinal value of -1 is entered. Then the program displays the count of the numbers entered and numeric average of the numbers

  2. programming

    create the logic for a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. create a separate method to do the calculation and return the result

  3. math

    If shipping charges to certain point 62 cents for the first five ounces and 8 cents for each additional ounce, the weight of a package, in pounds, for which the charges are $1.66 is not just an answer please A.7/8 B.1 C.1 1/8 D.1

  4. C++

    // Program: name of program // Author: your name // Date Written: date you began writing the program /* Abstract: Brief description of the program */ Include in-line comments in the body of your program. You can convert

  1. computer science

    a bank charges $10 per month plus the following check fees for a commercial checking account: $.10 each for fewer than 20 checks $.08 each for 20-39 checks $.06 each for 40-59 checks &.04 each for 60 or more checks write a program

  2. Medical coding Insurance Math

    Insurance Plan: Mountville Health Plan; patient has met annual deductible of $250;80-20 coinsurance. Services: CPT codes: 99203 and 90700. Usual charges are: $100& $102. Allowed charges are:$89 & $87 How do you calculate between

  3. computer programming

    Design the pseudocode for a program that allows a user to enter 10 numbers, then displays them in the reverse order of their entry

  4. Computer (Programming Logic and Design)

    How do i Create a program that determine the shipping cost for an order based on the following table: From To Price $0.00 $19.00 $2.95 $20.00 $49.99 $3.95 $50.00 $74.99 $4.95 $75.00 $1000.00 $Free I don't understand how to do

  1. Ethics

    1. Which of the following would be of greatest concern from an ethical standpoint? A. The number of homicide victims in a given place during a given time period B. The legal elements of the crime of homicide C. Whether capital

  2. ss

    many new industries are attracted to Georgia as a result of the 1. Okefenokee Swamp 2. Scenic mountain views 3. barrier islands 4. mild climate Which best explains why rivers of the coastal region are navigable? 1. the region is

  3. programming

    3. Create the logic for a program that accepts input values for the projected cost of a vacation and the number of months until vacation. Pass both values to a method that displays the amount you must save per month to achieve

  4. Medical coding

    Which of the following would be coded within the HCPCS Level II series code range of A4206-A8004? A. Ambulance ride to an emergency department. B. Artifical Kidney machine c. Commode chair d. Sterile needle HCPCS Level II drugs

You can view more similar questions or ask a new question.