Arduino code
Q: Write 2 different programs using if statement and switch statement that presents the iser w/ a…
A: Algorithm: Start Show the menu of beverages to the user and ask the user to choose Set amountPaid…
Q: Write a program that inputs a number and a letter and then decides whether the square is a black or…
A: Required: Write a program that inputs a number and a letter and then decides whether the square is a…
Q: Which of the following code is not correct ? Select one: a. if val(textbox1.text) >59 then…
A: For comparing text the raw data should be enclosed in double quotes at both the ends.
Q: Write a C program called “temp.c” that accepts a temperature in Celsius and prints the corresponding…
A: code snippet:
Q: > Example: Rewrite the previous code by using nested if condition. grade (x) := if x 2 60 out "you…
A: Here we are taking marks as an input and as a output we get grade of a student if student is less…
Q: Q3/ Using switch Write a Program to read the correct variable(x) then calculate and print the value…
A: I have used C language and also implemented a switch in this program. In step 2 I have added C code…
Q: Write a program for currency convertor for at least 30 countries. Get from the user using dialog box…
A: given data
Q: Correct the following code so that it prints the correct message. if (score <= 60)cout <<…
A: "if-else" statement: “if-else” statement is known as selection control structure. The syntax for…
Q: Convert the following if-else code to switch/case: if (code ==2 |l code == 4 |l code == 8)…
A: Following is the converted code:
Q: Using Switch statement, write a program that displays the following menu for the food items…
A: The choice and quantity will be the input Based on input choice we implement a switch block to…
Q: Rewrite this if/else if code segment into a switch statemen if (numBooks >=2 && numBooks 6 &&…
A: Given: if(numbooks>=2 && numbooks<=4) cout<<"you earned zero points \n";…
Q: (c) Write a program that asks the users to caleulate volume of a rectangular prism, in cm', where…
A: Given: To write a code.
Q: The following code displays double temperature = 42; if (temperature = 35) System.out.println("too…
A: if statements are used to check whether a set of condition is true/false
Q: / Write a program (using IF statement) to display the name of day by giving the day number as the…
A: The required Matlab program has been provided, by using if-else statements, in the next step.
Q: What is x after the following if-else statement is executed? Use a switch state- ment to rewrite it…
A: The condition else if(a==3) will be true only and the statement x+=16 will be executed. So the new…
Q: x = 2, y =1, z =3, what is the value of y after executing the following codes? switch(x) {…
A: Here we have to switch x . Given that value of x is 2. Therefore we will switch where the case…
Q: What is the output of the following code when x is .equal 5 * x = CInt(Text1.Text) If x = 1 Then…
A: output of the code:-
Q: iven an integer variable n: rite a few lines of code to: 2 if n is a multiple of 2 and not a…
A: Algorithm Start Var num Accept num from user if((num%2==0) and (num%4! =0) and (num%8! =0)) go to…
Q: Write C# program to print (Day/Night) program according to given D/N using the Switch Case. Enter…
A: Let's look at some syntax first: Print statement: In C# we can print statements using…
Q: Write a program to calculate the water bill amount using the formula. Amount= unit * rate + 3.0…
A: I didn't define any specific programming language for the problem, so i done it in c++ programming.…
Q: Write a C++ code that asks the user's name, then the code will ask the user to guess the password of…
A: #include <iostream>using namespace std;int main(){ int…
Q: x 2, y 1, z=3, what is the value of y after executing the following codes? switch(x) case 0: x =2;…
A: In switch case, statement when any case does not matches with required in switch then default case…
Q: What is the output for the following code snippet: area = 25 print("The area is %05d" % area) Select…
A: Since it is a python code
Q: Rewrite the following conditional expression with an if-else statement. sum *= x = = 2 ? y : 6 * y;
A: part-1. Given expression :- sum *= x==2?y:6*y; converting it to if-else statement - if(x == 2) {…
Q: Correct the following code so that it prints the correct message. (3) if (score <= 60) cout <<…
A: As per our honor code, we are answering the first question. Please post the remaining as separate…
Q: Write a program that prompts the user to enter the number of courses taken by a student. The program…
A: C++ used to answer this question
Q: Given x = 4; and y = 2; and operator = '-' ; what is the final value of x after the following switch…
A: When x=4, y=2, and operator='-' Then, final value of x is (4-2)= 2.
Q: Consider the code below. What is the output for x = 69? if x 10: print('Greater than 10') elif x >…
A: Question given - A Python code segment is given, that check a multiple if - elif - else statement…
Q: Write a program century.cc that prompts a user to enter a year between 1 and 2499, and prints its…
A: Time span of 100 years is known as century.
Q: Write a C++ code that asks the user's name then the code will ask the user to guess the password of…
A: Loop statement: Loop is a control statement that controls the flow of the execution of the…
Q: Write the code to check if y is between 80 and 100 (including 80 and not including 100)?
A: Given that, If the input number is between 80 and 100 then print Yes otherwise No.
Q: Write a C++ code that asks the user's name , then the code will ask the user to guess the password…
A: Program…
Q: Q2: Follow the code and correct the error if there is an error : Dim a as char="20" Dim a as…
A: the answer is as follows
Q: The statement: y = 0: 4:20 gives the same results as the tatomont y linspacol
A: Q: Answer given mcqs
Q: Sam is creating a code to determine whether an inputted value, x, is a positive or negative number.…
A: The correct answer along with the explanation is given below:
Q: What is the value of the following expression when a = 1, b = 1, and c = 0? The ^ symbol stands for…
A: Answer: False Explanation: Given values: a=1b=1c=0 Given expression: (a ^ b)(a ^ c) ^ - XOR
Q: The following expression will be evaluated to !(3 == 3 && 3 ==4 && 4 != 2); Select one: O True O…
A: && this is and operator . If any expression returns false then overall expression returns…
Q: Write a C++ code that asks the user's name, then the code will ask the user to guess the password of…
A: Here is your c++ code for guess game :- #include <iostream>using namespace std;int main() {…
Q: Write a C++ code that asks the user's name , then the code will ask the user to guess the password…
A: Given:
Q: Write a program that convert one killometer into miles per hour
A: (C++) #include <bits/stdc++.h>using namespace std; // Function to convert kmph to…
Q: Q1: What is wrong in the following code? if (score >= 60.0) cout « "Grade is D"; else if (score >=…
A: The code given is : if (score >= 60.0)cout « "Grade is D";else if (score >= 70.0)cout <«…
Q: What is y after the following switch statement is executed? Rewrite the code using an if statement.
A: Explanation of the code provided in question is as follow.. The first line of the code initializes…
Q: After the following statements, what are the values of x and y? * x - 15 y = x x - 22 O x is 15 and…
A: After the following statements, what are the values of x and y? * x = 15 y = x x = 22 O x is 15…
Q: If you have the following statements: int x = 0; for (x=1; x<4; x++); cout<<"x="<< x; The output…
A: 1) Code snippet in question does below activities it declare variable x initialize it to 0 Runs a…
Q: Rewrite the following conditional expression with an if-else statement. sum /= x = = 4 ? y : 6 + y;
A: Ternary operator tests a condition and executes blocks of code based on condition. Syntax-…
Q: Given x = 4; and y = 2; and operator = -' what is the final value of x after the following switch…
A: A switch is a control expression that allows one to choose one option from a list of options.…
Q: Using switch syntax to write a program that calculates and prints the bill for a cellular telephone…
A: Start Prompt the user to enter the account number and service code and store them in proper…
Q: Write a C program called “temp.c” that accepts a temperature in Celsius and prints the corresponding…
A: C programming is a general purpose, procedural and imperative computer programming language.
Q: What is the value of x after the following if-else statement is executed? Use a switch statement to…
A: Below are the answers for above questions with explanation:
Q: Correct the following code so that it prints the correct message.if (score <= 60)cout <<…
A: CORRECTED CODE: #include <iostream> // include header file for input output…
Write an Arduino code to control two LEDs using two push buttons, given the bellow setup:
- LED 1 is connected to pin 5
- LED 2 is connected to pin 4
- Button 1 is connected to pin 8
- Button 2 is connected to pin 9
If both push buttons are pressed, LED 1 is ON and LED 2 is OFF. If one of the push buttons is pressed LED 2 is ON and LED 1 is OFF.
hint: you may use the if..else if statement (note: you may use other approaches)
Step by step
Solved in 2 steps
- Q:Find the control word XOR A,B CW=? Your answerWrite pseudocode for an automatic hand sanitizer that displays green LED when the hand sanitizer solution is full, otherwise displays red LED when the hand sanitizer solution is near end. It also keeps check of how much hand sanitizer solution is pumped e.g. total is 500 ml, so each pump of hand sanitizer solution is 0.5 ml which is when it checks each pump using Infrared sensor.Programming Language: Java Direction: Write a program to determine the number of PASSED and FAILED out of 15 inputted names with the corresponding grade. Restrict the inputted grade for each name in the range of 50 to 100, in which 75 is the passing grade. If the inputted grade is not on the range, the program will remind the user of a message for the accepted range for the grade and allows the user to re-enter a grade. NOTE: MUST ADD COMMENTS
- Write aC++program that allows a user to enter their rating of the three movies in the DarkKnight Trilogy: Batman Begins/ The Dark Knight /The Dark Knight Rises Ratings must be between 1 and 5. If a rating entered is less than 1 or more than 5, display anappropriate message and do not use the rating. After all the ratings have been entered, display each rating entered, the highest rating, the lowest rating, and the average of the ratings.You are participating in a competition related to security, each participant is given a bank card and is asked to secretly set a 4-digit pin number for that card. The cards are then exchanged between participants. Each participant is given a card reading machine, where you can input the pin and the machine will tell you if the pin was correct or not. Your task is to find the pin entered by the other participant. A) What Al method will you use to obtain the 4-digit pin number stored in the card? [] B) Write a program in python that simulates the entire competition where the secret 4-digit number is entered by the user as an input. Then, simulate the card reader functionality where if the correct 4-digit key is provided it results with true value and false otherwise. Finally write your program that attempts to find the inputted number by using the simulated card reader only. [] C) Generate 100 random pins by going to the website https://www.coolgenerator.com/pin-generator. Run your code…HW 2: It is required from you to write a program by using switch statement for switch light with two buttons that are connected to two lights. The first situation you can chose either to switch ON one of these lights separately and printing out a message saying that, the light is switch ON. The second situation you can switch ON the two lights at the same time and the output message will say the 1 and the 2"d light are ON.
- What is y after the following switch statement is executed? Rewrite the code using an if statement.Write a flowchart and pseudocode like this: Pseudocode: Start inputmyNumber Set myAnswer-myNumber * 10 output myAnswer 1.The Dash Cell Phone Company charges customers a basic rate of $5 per month to send text messages. Additional rates are as follows: The first 100 messages per month, regardless of message length, are included in the basic bill. An additional three cents are charged for each text message after the 100th message, up to and including 300 messages. An additional two cents are charged for each text message after the 300th message. Federal, state, and local taxes add a total of 14 percent to each bill. THANKYOUUIn which cases you can transform an else-if statements to switch? Provide an example.
- Can Swap any two lines in the code only.Vary the control variable from 1 to 100 in increments of 1 .for (unsigned int i{1}; i <= 100; i++)Can provide a description outlining which option chosen and a description of how the code works and how to use it. Also can you fix the code. #Defining AND circuit def AND(a, b): #If both values are 1 return 1 if a == 1 and b == 1: return 1 else: #Otherwise return 0 return 0 #Defining OR circuit def OR(a, b): #If either of value is 1 return 1 if a + b == 1 or a == b == 1: return 1 else: #Otherwise return 0 return 0 #Defining NOT circuit def NOT(a): #If the input is 1 if a == 1: #Return 0 return 0 #If the input is 0 elif a == 0: #Return 1 return 1 #Defining NAND circuit def NAND(a, b): a = AND(a, b) if a == 1: return 0 else: return 1 #Defining NOR circuit def NOR(a, b): a = OR(a, b) if a == 1: return 0 else: return 1 #Defining XOR circuit def XOR(a, b): a = OR(AND(a, NOT(b)), AND(NOT(a), b)) if a == 1: return a else: return 0 #Defining NXOR circuit def…