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
Alja [10]
3 years ago
13

What type of selection can be used in leu of switch/case?

Computers and Technology
2 answers:
tankabanditka [31]3 years ago
7 0
An if or else statement can be
NikAS [45]3 years ago
6 0
In lieu of a switch/case statement, you can use an if/else statement. For example:

switch(x)
{
     case 100:
           System.out.println("Good grades! Keep it up!");
     case 50:
           System.out.printfln("Bad grades! Work harder!");
}


OR, you can use if/else:

if (x == 100):
          Sytstem.out.println("Good grades! Keep it up!");
if (x == 50):
          System.out.printfln("Bad grades! Work harder!");
You might be interested in
Write a function statement() that takes as input a list of floating-point numbers, with positive numbers representing deposits t
katrin2010 [14]

Answer:

def statement(numbers):

   deposits = []

   withdrawals = []

   for number in numbers:

       if number > 0:

           deposits.append(number)

       if number < 0:

           withdrawals.append(number)

   

   return [sum(deposits), sum(withdrawals)]

Explanation:

*The code is in Python.

Create a function called statement that takes numbers as a parameter

Inside the function, create two empty lists called deposits and withdrawals. Create a for loop that iterates through the numbers. Inside the loop, if a number is greater than 0, add it to the deposits. If a number is smaller than 0, add it to the withdrawals. When the loop is done, return the sum of the deposits and the sum of the withdrawals (use sum function to sum the numbers in the lists)

5 0
3 years ago
Write a method that accepts a String object as an argument and returns a copy of the string with the first character of each sen
emmainna [20.7K]

Answer:

The programming language is not stated; However, the program written in C++ is as follows: (See Attachment)

#include<iostream>

using namespace std;

string capt(string result)

{

result[0] = toupper(result[0]);

for(int i =0;i<result.length();i++){

 if(result[i]=='.' || result[i]=='?' ||result[i]=='!')  {

 if(result[i+1]==' ') {

  result[i+2] = toupper(result[i+2]);

 }

 if(result[i+2]==' ')  {

  result[i+3] = toupper(result[i+3]);

 }

 } }

return result;

}

int main(){

string sentence;

getline(cin,sentence);

cout<<capt(sentence);

return 0;

}

Explanation:

<em>The method to capitalize first letters of string starts here</em>

string capt(string result){

<em>This line capitalizes the first letter of the sentence</em>

result[0] = toupper(result[0]);

<em>This iteration iterates through each letter of the input sentence</em>

for(int i =0;i<result.length();i++){

This checks if the current character is a period (.), a question mark (?) or an exclamation mark (!)

if(result[i]=='.' || result[i]=='?' ||result[i]=='!')  {

 if(result[i+1]==' '){  ->This condition checks if the sentence is single spaced

  result[i+2] = toupper(result[i+2]);

-> If both conditions are satisfied, a sentence is detected and the first letter is capitalized

 }

 if(result[i+2]==' '){ ->This condition checks if the sentence is double spaced

  result[i+3] = toupper(result[i+3]);

-> If both conditions are satisfied, a sentence is detected and the first letter is capitalized

 }

}

}  <em>The iteration ends here</em>

return result;  ->The new string is returned here.

}

The main method starts here

int main(){

This declares a string variable named sentence

string sentence;

This gets the user input

getline(cin,sentence);

This passes the input string to the method defined above

cout<<capt(sentence);

return 0;

}

Download cpp
7 0
4 years ago
Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variable
Brilliant_brown [7]

Answer:

int main()

{

   double pH;

   int neutral;

   int base;

   int acid;

   cout<<"Enter a pH Value";

   cin>> pH;

   if(pH<7.0){

       neutral =0;

       base=0;

       acid= 1;

   }

   else if (pH=7.0){

       neutral =1;

       base=0;

       acid= 0;

   }

   else{

       neutral =0;

       base=1;

       acid= 0;

   }

   cout <<"The neutral, Base and Acid Values are: "<<neutral<<","<<base<<","<<acid<<" Respectively"<<endl;

   return 0;

}

Explanation:

Using multiple if/elseif/else statement the following problem is solved with C++

4 0
3 years ago
4. A computer architect boasted that they were able to design a computer in which every instruction occupied exactly thirty-two
Mariana [72]

Answer:

Advantages include;

1. It would take up less space.

2. Programs may require far less memory to run.

3. Less power wastage

Explanation:

Advantages include;

1. It would take up less space.

2. Programs may require far less memory to run.

3. Less power wastage

6 0
3 years ago
(TCO B) The symbol shown as a three-sided box that is connected to the step it references by a dashed line is what?
belka [17]

Answer: annotation symbol

Explanation:

The symbol shown as a three-sided box that is connected to the step it references by a dashed line is referred to as the annotation symbol.

The annotation symbol is referred to as a flowchart symbol that is used to hold comments. It is a tag that's applied to a family so that the family can be identified in a project.

4 0
3 years ago
Other questions:
  • You should code width and height dimensions for images because:
    15·1 answer
  • Paragraph: Read the following two e-mail messages. In a paragraph of no less than 125 words, explain why e-mail B is the more ap
    11·1 answer
  • You have found an old dusty computer in your basement that you can identify as an original IBM PC. You ask your friend if he kno
    15·1 answer
  • Computer user support helps people with minor computer problems. <br><br> True or False
    12·1 answer
  • An outline is most like which of the following?
    6·2 answers
  • A class can inherit behavior from a parent but also define its own and override parent behavior. This is called:
    8·1 answer
  • Select the correct term to complete the sentence.
    7·1 answer
  • Is orgenized maningful and useful data​
    15·1 answer
  • What is word processing program,Give 3 types of word processing program​
    9·1 answer
  • How can the absolute age of a rock be determined ?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!