Ask the user to enter 2 integers the second one being non-zero. Store these 2 values in int objects named a and b respectively. Use if/else selection statement to da the following: In the case the b is not zero: • compute the integer quotient of a/b and integer remainder a%b • store them into q and r. • output these values. In the case that b is zero: • output the message "Division by zero is undefined!" Sample output 1: Enter 2 integers (the second being non-zero): 15 6 q = 15 / 6 = 2 r = 15 % 6 = 3 Sample output 2: Enter 2 integers (the second being non-zero): 15 0 Division by zero is undefined!
Q: Given the declaration Circle x = new Circle(), which of the following statement is most accurate. a.…
A: EXPLANATION: In Java, an int is a primitive data type, but an Integer is a Wrapper class. The data…
Q: int main(void) { int a; char *s; int v0 = 9, v1 = 0, v2 = 0, v3 = 0;…
A: 1- Here the output is - Exercise 1:============ We use the variable to pass the value for the cases…
Q: * Returns a lowercase version of a user-entered letter * @param kbd * @return lowercase version of…
A: Input a character Convert to lower case Return the first character
Q: Ask the user for three ints (these can be entered in any order). Then print the values in order from…
A: A required C++ program is as follows, #include <iostream> int main() { //Declare the…
Q: One of the following is well defined: char a = ?ff int a=x6 char a = '?ff int a=_x6 Select one: a.…
A:
Q: I have no idea how to start this problem. This is the question - Write a program that declares two…
A: PROGRAM: //Importing time header file to access the functions import java.time.*; //Defining the…
Q: 8. Write a program that allows the user to enter two integers and a character If the character is A,…
A: As per our company guidelines, we are supposed to answer only one question per post and kindly…
Q: Analyze the following code. Is count < 100 always true, always false, or sometimes true or…
A: The collect program below Point A is always true in this program #include <iostream>using…
Q: PJ 2 is to write a C+ program to compute mortgage payment for a given loan amount, annual interest…
A: The amount and rate of interest and monthly payment is displayed with 2 point precision getpayment…
Q: Ask the user to enter the month of the year (number 1 through 12): “Enter the month of the year -…
A: The algorithm for the program would be as below:Declare one int variable for accepting user…
Q: Write an application that prompts a user for two integers and displays every integer between them.…
A: FIND INTEGERS INBETWEEN : 1. First create a class here it is called IntegerInbetween . 2. Create…
Q: Required programming is Java The use of computers in education is referred to as computer-assisted…
A: A java program for the given scenario is provided below,File name:"RandomGame.java"//Import required…
Q: Quiz 3.2: Question 3 Unlimited tries NOTE: in mathematics, division by zero is undefined. So, in…
A: Given data is shown below:
Q: What will be the value stored in the variable "s" after executing the following code segment? double…
A: Programming Approach: Defining the necessary header files. Defining the main function. Defining 2-D…
Q: he Billy Goat Fast-Fast Food restaurant sells the following products: Product Price ($)…
A: items = ['Cheeseburger','Pepsi','Chips']price = [2.49,1.00,0.59]print('Items\t\t\tPrice($)')for i in…
Q: // FixedDebugFive04 // Program prompts user for any number of values // (up to 20) // and averages…
A: Algorithm: Start Declare an array of 20 numbers Initialize a constant integer QUIT to 999…
Q: 2. Write an application that reads the (x,y) coordinates for two points. This should prompt for and…
A: Ans: Code: import java.util.Scanner;class Main{ public static void main(String arg[]) {…
Q: Write an application that allows a user to enter any number of student quiz scores, as integers,…
A: while ( true ) { ... if ( Condition ) { break; } ... } The above while-loop…
Q: Find the error in the following code: The following code was intended for inputting scores for 20…
A: Below i have highlighted the logical errors in BOLD and commented the wrong statement. Correct…
Q: QUESTION 8 You can cast a character value to an int, or an int to char. O true O false QUESTION 9…
A: Question 8 Int to character can be casted using various methods and character to int can be casted…
Q: Please tell me following code where is wrong and please explain to me. Thank you #include using…
A: A const pointer is a pointer whose address cannot be changed after initialization.
Q: java a. The user is prompted to enter an integer. If they enter something other than an integer,…
A: try {input = scanIn.nextInt();} catch (InputMismatchException ime) {input = -1;//set input to -1…
Q: What will be the value stored in the variable "s" after executing the following code segment?double…
A: The complete code segment according to c language is given by: #include<stdio.h>int…
Q: Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64!! Enter another integer: 5 4…
A: Your code is incomplete. Here is the fixed code:
Q: Write an application that accepts three Strings from the user and displays them in alphabetical…
A: Introduction of the Program: The Java Program takes three strings from the user as input then the…
Q: Write a statement that assigns numCoins with numNickels + numDimes. Ex: 5 nickels and 6 dimes…
A: PROGRAM INTRODUCTION: Import the required libraries. Start the definition of the main function.…
Q: Write an application that allows a user to enter any number of student quiz scores, as integers,…
A: PROGRAM CODE: import java.util.Scanner; public class Main { public static void main(String[]…
Q: Using Math.max and/or Math.min, write a class MaxOrMin, and make sure to use Math.max and Math.min…
A: As per our guidelines, we can solve the first three-part of the question.
Q: You have to 2 ints from the user( a and b) & print their sum on the console. However, sums in the…
A: Please find the answer below :
Q: After execution of the following code, what is stored in valueNum? All variables are using data type…
A: Given: All variables are using data type int. num1=3, num2=5, num3=7. To Find, The value stored in…
Q: Scanner input =new Scanner (System in), int answer, final int MIN NUM – 1; final int MAX NUM= 4,…
A: User inputs to cause the test to be true: The given “while” loop iterate until the condition…
Q: 2, Using Math.max and/or Math.min, write a class MaxOrMin, and make sure to use Math.max and…
A: Step 1 : Start Step 2 : In the main method, Create a scanner object. Step 3 : Declaring two integer…
Q: The value of a will become 3: int x = 2; x++; int a = (!5 == 5 + 2) ? 3>x ? 3: 5 : 4; cout << x;…
A: 1) In Above code segement we are using multiple conditions in Ternary Operator (?:) 2) We have two…
Q: int calculatepower (int x, int y) { if (y > 0) return x* else return 1; int main () { int num, pwr;…
A: Given:code reads two numbers from user : num, pwrand tries to print num to the pwr : num^pwrby…
Q: please only write the code in your solution goes here part do not change anything else C++ #include…
A: In this question we have to complete the CoordTransform function to change the coordinated and the…
Q: One or more of the following statements could be true. Tick the true statements and leave the false…
A: We will go one by one from the statments and try to understand them . In the first statment it is…
Q: Write an application that determines whether a phrase entered by the user is a palindrome. A…
A: import java.util.*; class palindrome{ void palin(){System.out.print("Enter the string you want…
Q: Assuming that a user enters 9, 23, and 3 as input values one after another, separated by spaces,…
A: In step 2, you will get the answer.
Q: Write an application that allows a user to enter any number of student quiz scores, as integers,…
A: import java.util.Scanner; import java.util.*; import java.util.Collections; class Main { public…
Q: int numl, num2, num3; double length, width, height; double volume; numl = 6; num2 = 7; num3 = 4;…
A: volume = box(length, width, height); valid. volume = box(length, 3.8, height); valid. cout…
Q: voidmain(){ inti=2; int i = 4, j = 5; printf("%d %d", i, j); printf("%d %d", i, j); ans. None of the…
A: According to the question variable value must be declare other wise you cant run the any of the…
Q: Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1…
A: Here have to determine java code for given problem.
Q: O of 3 points Quiz 3.2: Question 3 Unlimited tries NOTE: in mathematics, division by zero is…
A: PROGRAM INTRODUCTION: Take the number of calls received from the user. Take the number of operators…
Q: What is the sentinel value in the following code snippet? int main() { int score = 0; int…
A: In the given code snippet, -1 is the sentinel value.
Q: What is the value of maxNumber after the code that follows is executed?int number = 0;int maxNumber…
A: The program is a Java program which uses function random to generate random numbers between 0 and 1.…
Q: Write a program named TestsInteractive that prompts a user to enter eight test scores and displays…
A: NOTE - I have used Python programming language. Here I have created a list to store the scores.…
Q: Using Math.max and/or Math.min, write a class MaxOrMin, and make sure touse Math.max and Math.min…
A: Java codeimport java.util.Scanner; public class MaxOrMin {public static void main(String[]…
Q: Given that x = 0, what is the output of this code #include int main (void) { int x; printf…
A: GIVEN: Given that x = 0, what is the output of this code #include <stdio.h> int main (void)…
Q: What will the following code display?try:x = float('abc123')print(x)except IOError:print('This code…
A: Exceptions An exception occurs when some wrong input is being entered by the end-user or read from…
Step by step
Solved in 2 steps with 1 images
- // P41.cpp - A simple elevator for 4 floors and a basement with a // close door button and 5 keys for floors #include<iostream> #include<cmath> using namespace std; void close_door(); int change_floor(int choice, int floor); int main( ) { int key; int floor = 0; cout << "Press a Key \n"; cin >> key; if(key == 0) { close_door(); if( floor != 0){ // otherwise nothing happens cout << "I am moving to the Basement \n"; floor = change_floor(0, floor); } } else if(key == 1) { close_door(); if( floor != 1){ // otherwise nothing happens cout << "I am moving to the the First Floor \n"; floor = change_floor(1, floor); } } else if(key == 2) { close_door(); if( floor != 2){ // otherwise nothing happens cout << "I am moving to the the Second Floor \n"; floor = change_floor(2, floor); } } else if(key == 3) { close_door(); if( floor != 3){ // otherwise nothing happens cout << "I am moving to the the Third Floor \n"; floor = change_floor(3, floor); } }…8. Write a program that allows the user to enter two integers and a character If the character is A, add the two integers If it is S, subtract the second integer from the first if it is M, multiply the integers Display the results of the arithmetic The following problems requires nested if-statements9. Write a console-based application that asks a user to enter an IQ score. If the score is a number less than 0 or greater than 200, issue an error message; otherwise, issue an “above average”, “average”, or “below average” message for scores over, at, or under 100, respectively.10. Write a console-based program that prompts a user for an hourly pay rate. If the user enters values less than $7.50 or greater than $49.99, prompt the user again. If the user enters an invalid value again, display an appropriate error message. If the user enters a valid value on either the first or second attempt, display the pay rate as well as the weekly rate, which is calculated as 40 times the hourly rate.…A cashier distributes change using the maximum number of five dollar bills, followed by one dollar bills. For example, 19 yields 3 fives and 4 ones. Write a single statement that assigns the number of one dollar bills to variable numOnes, given amountToChange. Hint: Use the % operator. #include <stdio.h> int main(void) { int amountToChange; int numFives; int numOnes; scanf("%d", &amountToChange); numFives = amountToChange / 5; /* Your solution goes here */ printf("numFives: %d\n", numFives); printf("numOnes: %d\n", numOnes); return 0;
- What will be the value of ans after the following code has been executed? int x = 90, y = 55, ans = 10; if ( x == y); ans *= 2; 1. 10 2. 145 3. 20 4. None of theseImplement the following:Given:food1 = "Salad"food2 = "Sandwich"price1 = 3.6price2 = 4.99 Print two f-string statements to display the following according to the rules below:1) Food prefixed with "Lunch:"2) Price prefixed with "Cost: $"3) Food always has 25 characters of space.4) Price is always displayed with two decimal places. Just make sure to precisely match the output format below.Write your code in the ANSWER area provided below (must include comments if using code is not covered in the course).Example OutputLunch: Salad Cost: $3.60Lunch: Sandwich Cost: $4.99Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64!! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20 =================================== #include <stdio.h> int main(void) { int userNum; int userNum2; printf("Enter integer:\n"); scanf("%d",&userNum); printf("You entered: "); printf( "%d", userNum); printf("\n"); printf("%d", userNum); printf( " squared is "); printf("%d", userNum * userNum); printf("\n"); printf("And "); printf("%d", userNum); printf(" cubed is "); printf("%d", userNum * userNum * userNum); printf("!!"); printf("\n" "Enter another integer:\n"); scanf("%d",&userNum2); printf("\n"); printf("%d", userNum2); return 0;}
- Run the following code and answer the questions. #include <stdio.h> int main(void) { int a; char *s; int v0 = 9, v1 = 0, v2 = 0, v3 = 0; printf("Exercise 1:\n====================\n"); switch(v0) { case 0: printf("Good day\n"); break; case 1: printf("Hey There!\n"); break; case 2: printf("No Name\n"); break; case 3: printf("Yes Please\n"); break; case 4: printf("Go "); case 5: printf("Vamos!\n"); default: printf(" "); break; } for(v1; v1<v2; v1=v1+v1) { printf("Vamos "); } printf("\n"); if (v2 == 6) { s = "Go"; } if(v3 != 0) { printf("%s VAMOS!\n",s); } return 0; } What is the output of the program? Please explain why using the variables v0, v1, v2, and v3.…What is the value of maxNumber after the code that follows is executed?int number = 0;int maxNumber = 0;for (int i = 0; i <= 10; i++) { number = (int)(Math.random() * 100); if (number >= maxNumber) { maxNumber = number; }} a. the largest of ten random numbers from 0 to 99 b. the largest of eleven random numbers from 0 to 99 c. the largest of ten random numbers from 100 to 1000 d. the largest of eleven random numbers from 100 to 1000What will the following code display?try:x = float('abc123')print(x)except IOError:print('This code caused an IOError.')except ZeroDivisionError:print('This code caused a ZeroDivisionError.')except:print('An error happened.')print('The end.')
- In Chapter 4, you created a program that generates a random number, allows a user to guess it, and displays a message indicating whether the guess is too low, too high, or correct. Now, create a modified program called GuessingGame2 in which the user can continue to enter values until the correct guess is made. After the user guesses correctly, display the number of guesses made. Recall that you can generate a random number whose value is at least min and less than max using the following statements: Random ranNumber = new Random(); int randomNumber; randomNumber = ranNumber.Next(min, max);a. Write a program named CheckMonth that prompts a user to enter a birth month. If the value entered is greater than 12 or less than 1, display an error message; otherwise, display the valid month with a message such as 3 is a valid month. b. Write a program named CheckM0nth2 that prompts a user to enter a birth month and day. Display an error message if the month is invalid (not I through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between I and 29 for February). If the month and day are valid, display them with a message.Create a C# statement that uses each of the following built-in methods you have used in previous chapters, then make an intelligent guess about the return type and parameter list for the method used in each statement you created. a. Console.WriteLine() b. String. Equals() c. String. Compare() d. Convert.Tolnt32 () e. Convert. Tochar() f. Array. Sort()