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

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

'W', 'I'. Assume further that there are the following int variables, declared and already initialized: acount, bcount, ccount, dcount, ecount, fcount, wcount, icount. Write a switch statement that increments the appropriate 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:
d1i1m1o1n [39]3 years ago
6 0

Answer:

switch (grade) {

 case 'A':

   acount++;

   break;

 case 'B':

   bcount++;

   break;

 case 'C':

   ccount++;

   break;

 case 'D':

   dcount++;

   break;

 case 'E':

   ecount++;

   break;

 case 'F':

   fcount++;

   break;

 case 'W':

   wcount++;

   break;

 case 'I':

   icount++;

   break;

}

Explanation:

You might be interested in
You are asked to simulate a binary search algorithm on an array of random values.An array is the list of similar type of element
Alex Ar [27]

Answer:

Explanation:

Problem statement:

to simulate a binary search algorithm on an array of random values.

Binary Search: Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.

Input/output description

Input:

Size of array: 4

Enter array:10  20 30 40

Enter element to be searched:40

The Output will look like this:

Element is present at index 3

Algorithm and Flowchart:

We basically ignore half of the elements just after one comparison.

Compare x with the middle element.

If x matches with middle element, we return the mid index.

Else If x is greater than the mid element, then x can only lie in right half subarray after the mid element. So we recur for right half.

Else (x is smaller) recur for the left half.

The Flowchart can be seen in the first attached image below:

Program listing:

// C++ program to implement recursive Binary Search

#include <bits/stdc++.h>

using namespace std;

// A recursive binary search function. It returns

// location of x in given array arr[l..r] is present,

// otherwise -1

int binarySearch(int arr[], int l, int r, int x)

{

   if (r >= l) {

       int mid = l + (r - l) / 2;

       // If the element is present at the middle

       // itself

       if (arr[mid] == x)

           return mid;

       // If element is smaller than mid, then

       // it can only be present in left subarray

       if (arr[mid] > x)

           return binarySearch(arr, l, mid - 1, x);

       // Else the element can only be present

       // in right subarray

       return binarySearch(arr, mid + 1, r, x);

   }

   // We reach here when element is not

   // present in array

   return -1;

}

int main(void)

{ int n,x;

cout<<"Size of array:\n";

cin >> n;

int arr[n];

cout<<"Enter array:\n";

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

{ cin >> arr[i]; }

cout<<"Enter element to be searched:\n";

cin>>x;

int result = binarySearch(arr, 0, n - 1, x);

   (result == -1) ? cout << "Element is not present in array"

                  : cout << "Element is present at index " << result;

   return 0;

}

The Sample test run of the program can be seen in the second attached image below.

Time(sec) :

0

Memory(MB) :

3.3752604177856

The Output:

Size of array:4

Enter array:10  20 30 40

Enter element to be searched:40

Element is present at index 3

Conclusions:

Time Complexity:

The time complexity of Binary Search can be written as

T(n) = T(n/2) + c  

The above recurrence can be solved either using Recurrence T ree method or Master method. It falls in case II of Master Method and solution of the recurrence is Theta(Logn).

Auxiliary Space: O(1) in case of iterative implementation. In case of recursive implementation, O(Logn) recursion call stack space.

8 0
3 years ago
Describe two ways methods that cab be used to help stop hacking
mojhsa [17]

Answer:

Use a firewall

Install antivirus software.

Explanation:

7 0
2 years ago
jeremy wants to buy a horse. he is looking for a brown tennessee walker that is at least five years old and at least 15 hands ta
timurjin [86]

The numbers of records that will be displayed in response to his query is known to be zero (0).

<h3>What is a query?</h3>

A query is known to be a kind of a question or any form of request that is known to be for information that is often expressed in a formal manner.

Note that a database query is one that can be seen as an action query or a a kind of select query.

A select query is one that can help to get back data from a database. based on the question, Jeremy  is looking for a brown Tennessee walker and this is not among the option presented. Therefore the query will come back as zero.

Hence, The numbers of records that will be displayed in response to his query is known to be zero (0).

Learn more about query from

brainly.com/question/25694408

#SPJ1

7 0
1 year ago
Assume there is a variable, h already associated with a positive integer value. Write the code necessary to compute the sum of t
lions [1.4K]

Answer:

int i=1  // initialized i to 1

int q=0  // initialized q to 10

while((i*i)<h) // iterating the while loop

{

q=(i*i)+q  // calculating the sum of square

i=i+1 //Increment of i

}

Explanation:

Following are the description of Program

  • Initialized the variable "i" which is "int" type to 1.
  • Initialized the variable "q" which is "int" type to 0.
  • Iterating the while loop to less then variable "h".
  • In this loop we calculate the sum of square and holding the result in the variable "q".
  • Finally increment the value to "i" by 1 to iterating the loop.
6 0
3 years ago
How do i find the minterms
abruzzese [7]

Answer:

I think.....

Explanation:

bylooking

4 0
3 years ago
Other questions:
  • Christine wants to send a quick communication to all department managers. She should send a _____. report
    13·2 answers
  • Antivirus software installed to scan and monitor malware activities on a server or workstation would be identified as a ________
    8·1 answer
  • In his article “is google making up stupid” Nicholas Carr uses a metaphor to suggest that
    11·2 answers
  • What are some good electronics that I can buy on Amazon?
    14·1 answer
  • In this lab, you will create a programmer-defined class and then use it in a Java program. The program should create two Rectang
    14·1 answer
  • Clarice is an architect who is involved in design work on a restaurant in a building that used to be part of the city’s water wo
    8·1 answer
  • Paula weeded 40% of her garden in 8 minutes. How many minutes will it take to weed all of her garden at this rate ?
    7·1 answer
  • Website managers use____ every day.
    10·2 answers
  • How to send an email to multiple recipients individually outlook
    14·1 answer
  • PLEASE HELP!!! Me turn this into a video &amp; add liana flores- raise the moon (instrumental) in the background for the music.
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!