subject

Create a program that ask the user to enter the number of switches and calculates the possible outcomes that can come from those many number of switches (on / off).

Follow the steps given below to achieve the desired result:

● Step 1: Get the number of switches from the user and store it in a variable (lets

say switches).

● Step 2: Initialize 3 variables max_poss = 2, i = 1 and power = 1, where,

β—‹ max_poss = 2 denotes the maximum possibile outcome of 1 switch (i. e. on

and off),

β—‹ i is used to set the condition in while loop and it will keep incrementing

unless all the switches are over.

β—‹ power variable is further used to store the result.

● Step 3: Define a while loop with a condition to execute till the value of i is less

than or equal to switches.

● Step 4: Inside the while loop,

β—‹ Multiply the value stored in max_poss with power and store the result in

power.

β—‹ Increment the value of i by 1.

For eg: When switches = 2, In the

1st iteration, power = 2 and in the 2nd iteration, power = 2 * 2 i. e. 4. This indicates that, the

number of possible outcomes = 2switches, where switches denotes the number of

switches.

● Step 5: Print the total number of possible outcomes stored in variable power.
plss help me with this

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:50
Write a car class having two private member variables called tank and speed. write public methods called pumpgas and gofast. the method pumpgas gets an integer for gas that must be pumped. that value needs to be added to tank (no more than 20 gallons). it must return the amount of gas that is purchased ($4 per gallon). the method gofast should increase the speed by 5 each time it is called.write a constructor for the above class that initialized both variables to zero.write a tostring to display both the tank and speed when the car is printed.modify the car class to implement the interface comparable and an interface called carinter having the public methods in carinter.write the main program to create an array of size 5 of type car. create 5 car objects having each location of the array to refer to one of the cars. test the pumpgas, gofast, equals method on the array items. write an enhanced loop to print all the car values (using a tostring written last time).write a generic method to find the minimum of four items. pass int, double, char, string and car objects to test this method.
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
For her science class, elaine is creating a presentation on weather in the united states. she wants to make the presentation beautiful and interesting by drawing simple cloud or wave shapes. which is the best way for elaine to draw these shapes?
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Asecurity policy is a a. set of guidlines b. set of transmission protocols c. written document d. set of rules based on standards and guidelines
Answers: 2
question
Computers and Technology, 24.06.2019 00:40
To maintain clarity and focus lighting might be needed
Answers: 2
You know the right answer?
Create a program that ask the user to enter the number of switches and calculates the possible outc...
Questions