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
vesna_86 [32]
3 years ago
9

assume that grade is a variable whose value is a letter grade-- anyone of the following letters: 'A', 'B', 'C', 'D', 'E', 'F', '

W', 'I'. Assume further there are the following int variables, declared an already initialized: account, bcount, ccount, dcount, ecount, fcount, wcount, icount. Write a switch statement that increments the apropiate variable (acount, bcount, ccount, etc..) depending on the value of grade. So if grade is 'A' then acount is incremented; if grade is 'B' then bcount is incremented and so on.
Computers and Technology
1 answer:
eimsori [14]3 years ago
5 0

Answer:

Following are the Switch statement in C language is given below:

switch (grade)  //switch case

{

case 'A':  // case A

++acount; // incremented of acount

break;  // break the switch case

case 'B':  // case B

++bcount;  // incremented of bcount

break; // break the switch case

case 'C':  // case C

++ccount; // incremented of ccount

break; // break the switch case

case 'D':  //case D

++dcount; // incremented of dcount

break; // break the switch case

case 'E': //case E

++ecount;  // incremented of ecount

break;  // break the switch case

case 'F':  // case F

++fcount; // incremented of fcount

break;   // break the switch case

case 'W': // case W

++wcount;// increment of wcount

break; // break the switch case

case 'I': // Case

icount++;  // increment of icount variable

break;  // break the switch case

default: // default case

printf(" incorrect letter");/

}

Explanation:

The switch is used when we have multiple conditions and we have chosen only one condition.

The description of the statement is given below

  • In the switch condition, we have passed the char "grade" variable i.e switch(grade).
  • Inside the Switch case block, we have Created the cases 'A'.In Case A we have incremented the value of "acount " variable and break the case. The Same step is followed to create the case of B', 'C', 'D', 'E', 'F', 'W', 'I' respectively.
  • Suppose If the user Read character 'C' then control moves to the case 'C' . In that case, it firstly increments the value of "ccount" and break the switch case. The break statement is used for breaking the switch when a particular case is matched.
  • If the user Read incorrect character which is not matched with the cases than control moves to the default state and print "incorrect letter

You might be interested in
What is the definition of phishing with an example
Diano4ka-milaya [45]
Phishing is an ability of fraudulently obtaining personal info.
synonyms: Fraud and scam
8 0
3 years ago
I need help writing a recursion function to solve a boggle game for c++.
Mandarinka [93]

Answer:

#include <cstring>

#include <iostream>

using namespace std;

 

#define A 3

#define B 3

 

// LET US CREATE A DICTIONARY

string dict[] = { "KILLS", "GOT", "QUIZ", "GO" };

int n = sizeof(dict) / sizeof(dict[0]);

 

// Let us make a function to find whether a given word is present in dictionary.

bool isPresent(string& str)

{

   // linear search of words

   for (int i = 0; i < n; i++)

       if (str.compare(dict[i]) == 0)

           return true;

   return false;

}

 

// A function for printing all words present on Boggle

void findWordin(char bogle[A][B], bool hasbeenvisited[A][B], int i,

                  int j, string& str)

{

   hasbeenvisited[i][j] = true;

   str = str + bogle[i][j];

 

   // If str is in the dictionary, then you need to print it

   if (isPresent(str))

       cout << str << endl;

 

   // Travering adjacent 8 cells of the boggle

   for (int r = i - 1; r <= i + 1 && r < A; r++)

       for (int c= j - 1; c <= j + 1 && c < B; c++)

           if (r >= 0 && c >= 0 && !hasbeenvisited[r][c])

               findWordin(bogle, hasbeenvisited, r, c, str);

 

   // for erasing current characters on the string, and mark them visited

   // of the current cells to false  

   str.erase(str.length() - 1);

   hasbeenvisited[i][j] = false;

}

 

// Prints all words which are in dictionary.

void findWords(char boggle[A][B])

{

   // for marking all the characters as not being visited

   bool hasbeenvisited[A][B] = { { false } };

 

   // Initializing the present string

   string str = "";

 

   // Reading all the characters for finding all the words that begins with the above character

   for (int i = 0; i < A; i++)

       for (int j = 0; j < B; j++)

           findWordin(boggle, hasbeenvisited, i, j, str);

}

 

// the code for testing of the function

int main()

{

   char bogle[A][B] = { { 'k', 'I', 'L' },

                         { 'L', 'S', 'M' },

                         { 'G', 'O', 'T' } };

 

   cout << "Below list of words are present in the dictionary\n";

   findWords(bogle);

   return 0;

}

Explanation:

The program is properly commented, and that explains each step of it.  However, I have kept dictionary as constant for similifying the code. And it can be set to variable easily, if required.

7 0
3 years ago
Create a stored procedure sp_Q1 that takes two country names like 'Japan' or 'USA' as two inputs and returns two independent set
wolverine [178]

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

If you are executing this script with any other script, Add "GO" to the line above "CREATE PROCEDURE", on a line all by itself, and it should fix that error of 'CREATE/ALTER PROCEDURE'

Explanation:

CREATE PROCEDURE sp_Q1

"at"country1 NVARCHAR(15),

"at"country2 NVARCHAR(15)

AS

BEGIN

  BEGIN

      SELECT SupplierID, CompanyName, Phone, Country FROM suppliers

      where Country in ("at"country1,"at"country2)

     

  SELECT ProductID, ProductName, UnitPrice, SupplierID FROM Products

      where SupplierID in(

      SELECT SupplierID FROM suppliers

      where Country in ("at"country1,"at"country2)) ORDER BY SupplierID

  END

END

GO

-- Testing script.

DECLARE "at"RC int

DECLARE "at"country1 nvarchar(15)

DECLARE "at"country2 nvarchar(15)

-- Set parameter values here.

set "at"country1='UK'

set "at"country2='Canada'

EXECUTE "at"RC = [dbo].[sp_Q1]

"at"country1

,"at"country2

GO

5 0
4 years ago
All jobs that involve the web require a computer science degree true or false
Ipatiy [6.2K]

So I'd say false, I don't think that it's required to have a computer science degree but getting hired as a programmer without a computer science degree takes some work.

Please correct me if I'm wrong!! I'd be happy to fix it!! :)

7 0
3 years ago
Read 2 more answers
Need help !!!!!!!!!!!!!!!
Paladinen [302]

# 2 on the right goes to zipties

3 0
4 years ago
Other questions:
  • Which of the following is NOT a group on the Slide Master tab?
    6·1 answer
  • Which button is used to open the Start menu in Windows Vista?
    14·1 answer
  • which of the following sentences uses active voice?(answers to choose from are in the photo)-this is in my computer applications
    14·2 answers
  • An attacker has obtained the user ID and password of a data center's backup operator and has gained access to a production syste
    12·1 answer
  • Which of the following gadgets is best for making a soft-shell shape out of butter?
    15·2 answers
  • To obtain the desired speedup, make sure your new function recursively calls itself no more than once in the body of the method.
    8·1 answer
  • Zahra's softball team needs money for team T-shirts. The coach makes some fundraising suggestions, while team members brainstorm
    5·2 answers
  • Suppose we have two threads inserting keys using insert() at the same time. 1. (5 points) Describe the exact sequence of events
    11·1 answer
  • Given all of the limitations of MBR, is it still relevant in current day use?
    15·1 answer
  • From your analysis, do you think you’ve seen all of the servers and hosts that make up the Amazon e-commerce site? How does Amaz
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!