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
s2008m [1.1K]
2 years ago
7

IN C++ PLEASE!!!! Define a function FilterStr() that takes a string parameter and returns "Good" if the character at index 4 in

the string parameter is uppercase. Otherwise, the function returns "Bad".
Ex: FilterStr("sandwich") returns

Bad

Recall isupper() checks if the character passed is uppercase. Ex: isupper('A') returns a non-zero value. isupper('a') returns 0.

string's at() returns a character at the specified position in the string. Ex: myString.at(3)
)
#include
#include
#include
using namespace std;

/* Your code goes here */

int main() {
string input;
string output;

getline(cin, input);
output = FilterStr(input);
cout << output << endl;

return 0;
}
Computers and Technology
1 answer:
Ilia_Sergeevich [38]2 years ago
8 0

Answer:

Replace /*Your code goes here */ with

string FilterStr(string str){

   string retStr= "BAD";

   if(isupper(str.at(4)) != 0){

     retStr = "GOOD";

   }

   return retStr;

}

Explanation:

This defines the function

string FilterStr(string str){

This initializes the return string to BAD

   string retStr= "BAD";

This checks if the string at index 4 is uppercase;

   if(isupper(str.at(4)) != 0){

If yes the return string is updated to GOOD

     retStr = "GOOD";

   }

This returns the return string

   return retStr;

}

<em>See attachment for complete program</em>

Download cpp
You might be interested in
Write a program name Dollars that calculates and displays the conversion of an entered number of dollars into currency denominat
Cloud [144]

Answer:

I will code in Javascript.

Preconditions:

  • The variable dollar is passed by parameter to the function.

function Dollars(dollar) {

 

//declare and initialize the variables.

 var twenties = 0;

 var tens = 0;

 var fives = 0;

 var ones = 0;

 

<em>//If dollar is greater or equals 20, divide dollar by 20 and save it into the variable twenties. Then, save the remainder into the variable dollar.  </em>

 if(dollar >= 20){

   twenties = Math.floor(dollar/20);

   dollar = dollar % 20;

 }

<em>//If dollar is greater or equal 10, divide dollar by 10 and save it into the variable twenties. Then, save the remainder into the variable dollar.  </em>

 if(dollar>=10){

   tens = Math.floor(dollar/10);

   dollar = dollar % 10;

 }

<em>//If dollar is greater or equal 5, divide dollar by 5 and save it into the variable twenties. Then, save the remainder into the variable dollar.  </em>

 if(dollar>=5){

   fives = Math.floor(dollar/5);

   dollar = dollar % 5;

 }

<em> //If dollar is greater or equal 1, divide dollar by 1 and save it into the variable twenties. Then, save the remainder into the variable dollar.   </em>

 if(dollar>=1){

   ones = Math.floor(dollar/1);

   dollar = dollar % 1;

 }

//At this point, dollar is equal 0.It's time to display the conversion.

Console.log('20s :' + twenties);

Console.log('10s :' + tens);

Console.log('5s :' + fives);

Console.log('1s :' + ones);

}

Explanation:

The variable Math.floor(num) is used to round a number downward to its nearest integer.

For example, if dollar=57:

twenties = dollar/20 will be 57/20 = 2

dollar = dollar % 20 will be 57 % 20 = 17

tens = dollar/10 will be 17/10 = 1

dollar = dollar % 10 will be 17 % 10 = 7

fives = dollar/5 will be 7/5 = 1

dollar = dollar % 5 will be 7 % 5 = 2

ones = dollar/1 will be 2/1 = 2

dollar = dollar % 1 will be 0 % 5 = 0

7 0
3 years ago
At year end, Clean123 Inc. has 45500 in cash, 55000 in accounts receivable, 54400 in service equipment, 550 in prepaid insurance
Inessa [10]
Oh ok so yea and why you should but I
8 0
2 years ago
3. The following code will not display the results expected by the programmer. Can
Elena L [17]

Answer:

ion k

Explanation:

7 0
3 years ago
Rectangle perimeter is 72 .Find the new perimeter if length is doubled and breadth is tripled​
777dan777 [17]

Answer:

Is it related to technology and computers?

3 0
2 years ago
As Jason walks down the street, a large raven starts squawking at him and flapping its wings. Jason thinks to himself ‘That bird
UNO [17]

Answer:

Answer to the following question is anthropomorphism.

Explanation:

Anthropomorphism is considered as the error in the following context of the scientific reductionism. Anthropomorphize is the source of an error that needs to reconsider.

Anthropomorphism is an attribute of the human qualities, emotions, thoughts, motivation, intentions, and characteristics to the non-living beings or the nonhuman beings, things or objects.

8 0
2 years ago
Other questions:
  • After doing the route tracing to a particular IP addresses, paste the path of IP addresses that were taken from your IP address
    13·1 answer
  • The operating system of a computer is an example of ________ software. science-forum
    7·1 answer
  • Enter a formula using a database function to calculate the total value in the Cost column for expenses that meet the criteria in
    12·1 answer
  • To what would you compare the transport layer?
    14·1 answer
  • . What is the relationship between frequency, wavelength and speed of a wave?
    15·1 answer
  • We already know that we can create a lunar lander application of the pipe-and-filter architecture style from three independent J
    6·1 answer
  • Write a java program to find the perimeter of a triangle with sides measuring 10cm, 14cm and 15 cm.
    8·1 answer
  • A company is deploying NAFDs in its office to improve employee productivity when dealing with paperwork. Which of the following
    11·1 answer
  • What might a designer need to consider when choosing an appropriate energy source for products and power systems
    15·1 answer
  • Discuss new concepts that you have learned about Cisco Devices and how they will be helpful in the workplace.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!