CHALLENGE 3.17.2: Conditional assignment. ACTIVITY Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and updateDirection is 1, numUsers becomes 9; if updateDirection is 0, numUsers becomes 7. Hint: Start with "numUsers = ..". 1 #include 2 using namespace std; 1 test 3 passed 4 int main) { int numUsers; int updateDirection; 6 All tests 7 passed cin >> numUsers; cin updateDirection; 10 /* Your solution goes here */ 11 12 numUsers << endl; cout <<"New value is: 13 14 return 0; 15 16 Run
Q: Write declarations to declare each variable to have the specified type and initial value: Problem:…
A: Variable declaration: A variable is a name that is the name given to a memory location in computer…
Q: a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print…
A: I have provided a detailed code below.
Q: What will be output to the screen when the following code is executed: def PrintMe(x): try: return…
A: The problem is based on the basics of functions in python programming language.
Q: Which class variable in class MyC. cannot be inherited by class xxx? class MyC: X,y=3,4%3;…
A: Inheritance is a property of accessing the properties of a parent class Here, MyC is the parent…
Q: class Line: '''write your codes below (don't forget to change the doc strings)''' def…
A: class Line(object): k=0 b=0 def __init__(self, k, b): self.k=k…
Q: Write multiple if statements:If carYear is before 1967, print "Probably has few safety features."…
A: Multiple if-statement includes many if-statements. In multiple if-statement, one or more…
Q: def foo(arg): if isinstance (arg, -): 11 oops return 'yeah' else : oops yeah return 'oops' 12 print…
A: Here, Code is given.
Q: CHALLENGE ACTIVITY 422784.2543518.qx3zqy? Jump to level 1 Write an if-else statement for the…
A: If user Tickets is less than 8, execute award Points = 1. Else, execute award Points = User Tickets.
Q: -E4.24 Implement a class Balloon that I with air. The constructor methods: •void addAir (dou •double…
A: Source Code:- Balloon.java public class Balloon { private double radius; public Balloon() { } //adds…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: The correct answer is (E) Seed Explanation: The composite class known as a concrete component class…
Q: eate a class named as Integer by using a logical NOT operation that converts the positive number in…
A: import java.util.*;public class Main{ public static void main(String[] args) { Scanner sc=new…
Q: Task 6 Implement the design of the Laptop class so that the following output is| produced [You are…
A: Note: - As per the guidelines we can only answer one specific question at a time. Please resubmit…
Q: 21 When an object listener is registered with several components, the way we distinguish between…
A: Given:
Q: in java eclipse ide Write a program: Input from console 2 integer numbers, save them in…
A: I give the code in java eclipse and also provide the output and code screenshot
Q: 1. (Composition) Write a Pizza class so that this client code works. Please note that it is ok if…
A: # The Pizza class should have two attributes(data items): class Pizza: # The Pizza class should…
Q: CHALLENGE ACTIVITY 422784.2543518.qx3zq7 Jump to level 1 Write an if-else statement for the…
A: The answer for the above question is given in the below steps.
Q: Create a JavaFX application that lets the user play the game of rock, paper, scissors against the…
A: Actually, Java is a high level programming language... And also object oriented .It. Is a platform…
Q: Q.1) Write a java program with class name Lock that allow the users to enter their name and the lock…
A: use two variables name and lockNumber to store values input by user. use remaining and count two…
Q: 18.14 Define a method named coinFlip that takes a Random object and returns "Heads" or "Tails"…
A: import java.util.Scanner;import java.util.Random; public class LabProgram { /* Define your method…
Q: Task 6 Implement the design of the Laptop class so that the following output is produced [You are…
A: Let's understand step by step : 1. lenovo = Laptop("Lenovo",5) So there will be class Laptop whose…
Q: Add workshop 2. In JavaFX, implement the functionality of making a popup appear on the screen when…
A: JavaFx: JavaFX is Associate in Nursing open supply, next generation shopper application platform for…
Q: K Chapter 4 Project - new Fall 10-21-20... Project Name: Chpt4_Project Class Name: Chpt4_Project…
A: Java program that accepts names of members on a tug of war team, computes their total weight, and…
Q: Using a conditional expression, write a statement that increments numUsers if updateDirection is 1,…
A: As the whole program is already designed We will use the conditional statement i.e (if else) to…
Q: TASK Write a program that grades students' exam. The exam has 20 multiple choice questions. Here are…
A: class StudentExam{ private: static char key[]; char ans[21],missed[21];…
Q: Basic if-else expression. Jump to level 1 Write an expression that will cause the following code…
A: Solution: Algorithm Step 1: Input age from the user. Step 2: If the age is less than or equal to…
Q: odify the Percentages2 class derived from Chapter 3 Exercise 5A to accept the values of the two…
A: Required: Modify the Percentages2 class derived from Chapter 3 Exercise 5A to accept the values of…
Q: 1. Assume x is an int which has been declared and assigned a valid value. x guaranteed to change…
A: The given code is used the multiple if statement, in which control is evaluate both if statement…
Q: Task 6 Implement the design of the Laptop class so that the following output is produced [You are…
A: Code:- class Laptop: #declare a class called Laptop laptopCount=0 #initialize laptopCount to…
Q: CHALLENGE 2.1.3: Basic if-else. ACTIVITY 422784.2543518.qx3zqy7 Jump to level 1 Write an if-else…
A: The code implementation in Java is given below. Algorithm: Begin. Prompt the user to input the…
Q: After following statements have executed, what will be appear on the output window int i=10, a=0;…
A: Please find the answer below :
Q: Write an application that displays a menu system. The menu system should allow the user to select…
A: Program: import java.awt.GridLayout;import java.awt.event.ActionEvent;import…
Q: Write an if-else statement for the following: If userTickets is less than 8, execute awardPoints =…
A: The main advantages of high-level languages are:- - human-friendly - machine-independent - easy to…
Q: BJP4 Exercise 4.16: printPalindrome Write a method called printPalindrome that accepts a Scanner…
A: PROGRAM: //Header file import java.util.Scanner; //Defining the main() class Main {…
Q: (Java) Q 1,2 ANSWER BOTH PART 1 AND 2!!! Explain the answer step-by-step and include verbal…
A: I updated the code and also provide the output screenshot and code as per your requirement
Q: Complete the code below according to the instructions below and the example test: method withdraw…
A: Here we have to implement withdraw which might throw an Exception when if requested amount is more…
Q: Use a Bootstrap class to center the following text: Hello World!
A: Ans : Use a Bootstrap class to center the following text: <p class="text-center">Hello…
Q: Task 3 Implement the design of the Passenger class so that the following output is produced: The…
A: Given:
Q: CHALLENGE ACTIVITY 422784.2543518.qx3zqy7 Jump to level 1 Write an if-else statement for the…
A: #include <iostream>using namespace std; int main(){ int awardPoints; int userTickets;…
Q: Write a console application that prints the next 20 leap years. A leap year is a year in which an…
A: Programming is a way to instruct the computer devices to operate. Every computer needs a set of…
Q: char xusername[10]; char xbankname[10]; int xaccountnum[4]; int xcardnum[14]; int…
A: Flow chart is a step by step process of the program which is represented using different symbols and…
Q: The result of the following lines: const int myNumber = 10; myNumber = 13;…
A: The given C# code has: One constant variable "myNumber" which initializes as 10. The value of…
Q: Task - 3 Write the CheckingAccount class so that the following code generates the output below:…
A: 1) Below is program that includes CheckingAccount class to generate the output It defines Account…
Q: Activity 3: Using the scanner class create a java code segment that will enable user interactions…
A: In this question, we are asked to write the java code using scanner class for the user input Syntax:…
Q: Predict the output? #include using namespace std; class ClassA { public:…
A: Question 3. Predict the output? #include<iostream> using namespace std; class ClassA {…
Q: Can you add class level comments, function level comments and inline comments In this line int…
A: I have added all comments and solved all errors in step2.
Q: CHALLENGE 2.1.3: Basic if-else. ACTIVITY 4227842543518.37 Jump to level 1 Write an if-else statement…
A: The answer is given below. Algorithm: Input value of userTickets. If userTickets less than 8 print…
Q: Using javascript getElementByClass- write a simple programe whereby each time a player gets shot by…
A:
Q: Craps is a single player dice game, that proceeds as follows: 1. the player rolls 2 six-sided dice…
A: Code: The python program is given by import random #function to calculate the sum of 2…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- Again --4. Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate. The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in __main__ and print the ValueError message along with "Could not calculate heart rate info." Ex: If the input is: 35 the output is: Fat burning heart rate for a 35 year-old: 129.5 bpm If the input is: 17 the output is: Invalid age. Could not calculate heart rate info.?.2.1.2: Basic if-else expression. Jump to level 1 Write an expression that will cause the following code to print "I am an adult" if the value of userAge is greater than 19. import java.util.Scanner; public class AgeChecker { public static void main (String [] args) { int userAge; Scanner scnr = new Scanner(System.in); userAge = scnr.nextInt(); // Program will be tested with values: 18, 19, 20, 21. if (userAge > 17) { System.out.println("I am a teenager"); } else { System.out.println("I am an adult"); } }}1. Replace the (????) with relevant code to make th eprogram function. Details about the code are given below:(Java as been used) a) This program creates a reference to a file in main() and passes the reference to countWords() countWords(), not main(), reads the file and displays Total lines Total words Average words per line */ package finalexamtakehome1; import java.io.*; /** * * @author sweetkim */ public class Finalexamtakehome1 { // public static void countWords(????) { int lineCount = 0; int wordCount = 0; while (????()) { String line = input.nextLine(); lineCount++; Scanner lineScan = new Scanner(line); while (????()) { String next = lineScan.next(); wordCount++; } } double averageWords = (double) wordCount / lineCount; System.out.println("Total lines = " + lineCount); System.out.println("Total words = " + wordCount); System.out.printf("Average words per line =…
- 12. What is the output of the following program? (2, 3, 6, 8) #include #include #include #include using namespace std; int main() { double x, y; string str; x = 9.0; y = 3.2; cout (sqrt(pow (y, 4))) = " (sqrt(pow (y, 4))) << endl; str = "Predefined functions simplify programming code!"; cout << "Length of str = " << str.length() << endl; return 0; }7.21 LAB: Random values use Java. In the file RandomNumbers.java, write a class called RandomNumbers that has three integer instance variables: var1, var2, and var3. Write getter method for each variable: getVar1(), getVar2() and getVar3(). Then write the following 2 instance methods: setRandomValues( ) - accepts a low and high integer values as parameters, and sets var1, var2, and var3 to random numbers (generated using the Random class) within the range of the low and high input values (inclusive). getRandomValues( ) - prints out the 3 random numbers in the format: "Random values: var1 var2 var3" Ex: If the input is: 15 20 the output may be: Random values: 17 15 19 where 17, 15, 19 can be any random numbers within 15 and 20 (inclusive). Note: When submitted, your program will be tested against different input range to verify if the three randomly generated values are within range. import java.util.Scanner; public class LabProgram {// main method used to test your codepublic…### welcome_assignment_answers### Input - All nine questions given in the assignment.### Output - The right answer for the specific question. def welcome_assignment_answers(question): #Students do not have to follow the skeleton for this assignment. #Another way to implement is using a "case" statements similar to C. if question == "Are encoding and encryption the same? - Yes/No": answer = "The student should type the answer here" elif question == "Is it possible to decrypt a message without a key? - Yes/No": answer = "The student should type the answer here" else: ### you should understand why this else case should be included ### what happens if there is a typo in one of the questions? ### maybe put something here to flag an issue and catch errors answer = "This is not my beautiful wife! This is not my beautiful car! How did I get here?" return(answer)# Complete all the questions. if __name__ == "__main__": #use this…
- ### welcome_assignment_answers### Input - All nine questions given in the assignment.### Output - The right answer for the specific question. def welcome_assignment_answers(question): #Students do not have to follow the skeleton for this assignment. #Another way to implement is using a "case" statements similar to C. if question == "Are encoding and encryption the same? - Yes/No": answer = "The student should type the answer here" elif question == "Is it possible to decrypt a message without a key? - Yes/No": answer = "The student should type the answer here" else: ### you should understand why this else case should be included ### what happens if there is a typo in one of the questions? ### maybe put something here to flag an issue and catch errors answer = "This is not my beautiful wife! This is not my beautiful car! How did I get here?" return(answer)# Complete all the questions. if __name__ == "__main__": #use this…### welcome_assignment_answers### Input - All nine questions given in the assignment.### Output - The right answer for the specific question. def welcome_assignment_answers(question): #Students do not have to follow the skeleton for this assignment. #Another way to implement is using a "case" statements similar to C. if question == "Are encoding and encryption the same? - Yes/No": answer = "The student should type the answer here" elif question == "Is it possible to decrypt a message without a key? - Yes/No": answer = "The student should type the answer here" else: ### you should understand why this else case should be included ### what happens if there is a typo in one of the questions? ### maybe put something here to flag an issue and catch errors answer = "This is not my beautiful wife! This is not my beautiful car! How did I get here?" return(answer)# Complete all the questions. if __name__ == "__main__": #use this…Write a code in JAVA for the following. A university is going to conduct the placements for the students. Various companies will visit the campus for recruiting the students based on the following requirements. Wipro: GPA is >7, Backlogs allowed upto 2 IBM: GPA is >8, Backlogs allowed is 0 TCS: GPA is >=6, Backlogs allowed 1 Google: GPA is >9, Backlogs allowed 0 Write a java program that defines a custom exception named “NotEligibleException”. Create classes for the above mentioned companies. Define a method to find the eligibility according to the above requirements. If the above requirements are met by the student, he/she is eligible for attending the interview. Otherwise “NotEligibleException” should be thrown and handle that exception. Input to the program is student grade and the number of backlogs. Ex: Expected input and output Input: 8,3 6,0 7,0 9,1 Output: Not Eligible for Wipro Placements Not Eligible for IBM Placements Eligible for TCS Placements Not Eligible for…
- Write code that uses a std::map to create a food inventory. We will use a food's name as the key to store the corresponding quantity. Add the following information to the map: 1 Apple, 5 bananas, and 3 milk. Ask the user for the updated number of bananas in the inventory and update the map accordingly. Use the map to display the quantities of each item. #include <iostream> #include <map> int main() { int new_banana_count = 0; // TODO: Instantiate a std::map using its default constructor to represent a food inventory. // TODO: Add 1 Apple, 5 Bananas, and 3 Milk to the food inventory. std::cout << "Updated amount of bananas: "; std::cin >> new_banana_count; // TODO: Update banana count std::cout << "Number of apples: "; // TODO: Display number of apples std::cout << "\nNumber of bananas: "; // TODO: Display number of bananas std::cout << "\nNumber of milk: "; // TODO: Display number of milk return 0; }Define a class called GATE consisting of members Name, College, Qualification, Email, and CGPA. Define a function called read() to receive values for the above members. Create custom defined exceptions “InvalidEmailException”, “InvalidCGPA” and “NotEligibleQualification”.Raise “NotEligibleQualification” if the qualification is not any of these values: B.Tech / BE.Raise “InvalidCGPA” if the CGPA is not with in range 0 to 10.Raise “InvalidEmailException” if the email-id doesn’t contain a ‘@’ or ‘.’ symbol in the appropriate places.class Line:'''write your codes below (don't forget to change the doc strings)'''def __init__(self, k, b):'''write your codes below (don't forget to change the doc strings)'''def __repr__(self):'''printable representation of the line by equation y = k*x+b'''return 'line y = %r*x + %r' % (self.k, self.b) def __add__(self,other):'''write your codes below (don't forget to change the doc strings)'''def intersect(self,other):'''write your codes below (don't forget to change the doc strings)'''