1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
White raven [17]
3 years ago
6

Write a C++ program that displays the appropriate shipping charge based on the region code entered by the user. To be valid, the

region code must contain exactly three characters: a letter (either A or B) followed by two numbers. The shipping charge for region A is $25. The shipping charge for region B is $30. Display an appropriate message if the region code is invalid. Use a sentinel value to end the program. Save and then run the program. Test the program using the following region codes: A11, B34, C7, D2A, A3N, C45, and 74TV.
Computers and Technology
1 answer:
gregori [183]3 years ago
3 0

Answer:

Following are the code to the given question:

#include <iostream>//header file

#include <string>//header file

using namespace std;

int main()//main method

{

string region;//defining a string variABLE

while(true)//defining a while loop for input value

{

cout << "Enter the region code(-1 to quit): ";//print message

cin >> region;//input string value

if(region == "-1")//defining  if to checks string value

{

break;//use break keyword

}

else//else block

{

if(region.length() != 3)//defining if to check string value length not equal to 3  {

cout<<"Invalid region code. Region code must contain exactly three characters."<<endl;//print message

}

else

{

if(region.at(0) == 'A' || region.at(0) == 'B')//defining at method that checks string value

{

if((region.at(1) >= '0' && region.at(1) <='9') && (region.at(2) >= '0' && region.at(2) <='9'))//defining at method that checks string value

{

if(region.at(0) == 'A')//defining at method that checks string value

{

cout<<"The shipping charge for region is $25."<<endl;//print message

}

else

{

cout<<"The shipping charge for region is $30."<<endl;//print message

}

}

else

{

cout<<"Invalid region code. Region code should start with A or B followed by two numbers."<<endl;//print message    

}

}

else

{

cout<<"Invalid region code. Region code should start with A or B."<<endl;//print message

}

}

}

}

return 0;

}

Output:

Please find the attached file.

Explanation:

In this code, inside the main method a string variable "region" is declared that use while loop to the input value and use the conditional statement that checks the input value and print the value as per the condition and print the value.

You might be interested in
Which method will return the first element in an ArrayList employees?
Wittaler [7]

Answer:

employees.get(0)

Explanation:

In the programming, the index of ArrayList start from zero.

So, the element start storing in the ArrayList from the zero index.

get() is the function which is used to retrieve or getting the value in the

ArrayList.

The function employees.get(0), it retrieve the element of zero index.

The function employees.get(1), it retrieve the element of first index.

The function employees.first(1), it is wrong calling.

The function employees.get(), it is wrong calling. you have to enter the index value inside the get().

3 0
3 years ago
Your friend sends you a computer game. after installing the game on your computer, you realize that it plays very slowly. you kn
dsp73
Memory possibly. Or another pricessor.
8 0
3 years ago
For question 1-3, consider the following program: def tryIt(a ,b = 7) return a + b
tino4ka555 [31]

Answer:

1)18

2)4

3)28

Explanation:

1) ans= tryIt(2) *2

        = (2+7)* 2 =18

2) ans= tryIt(-5) *2

        = (-5+7)* 2 =4

3) ans= tryIt(7) *2

        = (7+7)* 2 =28

3 0
3 years ago
________ is the process of translating a task into a series of commands that a computer will use to perform the task.
IgorC [24]
Programming 
It can also be described as Reverse Engineering 
7 0
3 years ago
¿Qué creo que debe considerar una empresa para elegir ellugar en el cual va a desarrollar su actividad económica osu emprendimie
zhannawk [14.2K]

Answer:

sorry I don't speak that language

8 0
3 years ago
Other questions:
  • What variation of a dictionary attack involves a dictionary attack combined with a brute force attack, and will slightly alter d
    9·1 answer
  • A digital footprint is all of the information on-line about a person posted by that person or others, ____________. intentionall
    14·1 answer
  • When a computer is booted the checks the computer's components?
    7·1 answer
  • You are trying to log in to your old computer, and can't remember the password. You sit for hours making random guesses... I'm s
    10·1 answer
  • Operating systems provide a measure of security by allowing users to access to those resources they've been cleared to use as we
    8·1 answer
  • The transmission control protocol (TCP) layer helps computers to communicate in which of the following ways?
    10·1 answer
  • What is the console.log function for?​
    13·1 answer
  • I'm having trouble with an assignment of mine. I'm making a text based adventure game for extra credit in my class and I'm stuck
    12·1 answer
  • Identify and explain groups that may be impacted by nanotechnology.
    13·1 answer
  • Match each type of video camera to its features:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!