Suppose you shop for rice in two different packages. You would like to write a program to compare the cost. The program prompts the user to enter the weight and price of each package and displays the one with the better price.
Q: For reproducibility needed for auto-grading, seed the program with a value of 2. In a real program,…
A: The seed value is generally declare while creating instance of Random Numbers
Q: 3. Write a program that reads an integer between 0 and 1000 and adds all the digits in the integer.…
A: The Answer is in given below steps
Q: 2) A BMI Calculator: the body mass index (BMI) is a measure used to determine whether a person is…
A: Java Code import java.util.Scanner; public class Test { public static void main(String[] args) {…
Q: Q1. Write a program that takes a range from the user and display all the even numbers between the…
A: /* C++ program to print the even numbers within the given range */ #include…
Q: 3. Write a program that plays a guessing game with the user. The program should generate a random…
A: According to the information given:- We have to follow the instruction in order to create guess game…
Q: Q1: Write a program that reads a set of N integers. Then, the program finds and outputs the sum of…
A: Below I have provided a python program for the given question. Also, I have attached a screenshot of…
Q: 3. B) What is the value of num when the following code snippet runs successfully? int num = 100;…
A: I give the solution to both with output screenshot I also give the code ,output and code screenshot…
Q: Q1: Write a program that reads 10 numbers and then finds the largest number and prints it and finds…
A: - The question wants us to find the largest and smallest number after reading 10 numbers and print…
Q: trace the following code and give the output. for (int value =3; pow (2, value) <=100; value++)…
A: Tracing the code: A variable “value” is initialized to 3. A "for" loop iterates till “pow(2, value)…
Q: Q2: Write a program that inputs a five-digit integer, separates the integer into its individual…
A: Code
Q: (Display Magic Numbers) Display the first N magic numbers, where N is a positive number that the…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: QUESTION 10 def cube (number): for i in range (number, number): for j in range (number) : print…
A: In place of FILL THIS PART just write number*number*number Hence the answer to be filled in the box…
Q: Homework01. Write a Java program that prompts the user to enter the seconds as a String (e.g.,…
A: - The question is to complete the conversion.
Q: 5: CheckLetter.cpp) Write a program that adds a check letter to an eight-digit number. The check…
A: CODE:- #include <iostream>using namespace std; char letter(int n){ //split into 4 two digit…
Q: What is the value of num3 after the following code is executed: int num1; int num2; int num3; num1 =…
A: value of num1 is 15.
Q: Using While Loop in Java Write a program that let the user include his or her three (3) grades.…
A: Algorithm Start Var grade [3], sum=0 Accept all 3 grade from user Compute sum of these grade in sum…
Q: (x) int main() (1) { int myList[ 3 ][ 3 ] =({1,2,3},{4,5,6},{7,8,9}}; (2) (x) (3) (4) (5) (x) (6)…
A: In the above code we have to find that which line contains error in the code and then write the…
Q: Write a program in which user is asked to enter two integers (divisor and dividend) and computes the…
A: Program Explanation :- In this Program, the user is required to enter two numbers (separator and…
Q: Write pseudo code that will calculate a running sum. A user will enter numbers that will be added to…
A:
Q: Arranging Pebbles Write a program that can arrange a group of pebbles into its designated position.…
A: i give this question answer program with number of integer we describe, first take number of colur…
Q: Write pseudo code that will count all the even numbers up to a user defined stopping point. (Please…
A: any number which is completely divisble by 2 is even number. So logic is use % (mod) operator and…
Q: Write a program that simulates flipping a coin to make decisions. The input is how many decisions…
A: For the given question, we have to design a Python program that does/includes the following :…
Q: or faster sorting of letters, the United States Postal Service encourages companies that send large…
A: Encoding number system:- Interchange (ASCII) The most widely used coding scheme is still ASCII.…
Q: Activity #2: Write a program that computes parking fees for a garage with the fee structure given in…
A: Objective: This program reads the number of hours parked for vehicles and computes the total charge.…
Q: A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her…
A: Program Approach Make a method to return the total calories from number. Input the Fat Grams.…
Q: What is the value of num3 after the following code is executed: int num1; int num2; int num3; num1 =…
A: // Online Java Compiler// Use this editor to write, compile and run your Java code online class…
Q: in this program. a, int b, int *c, int *d, int *resu a, int *b, int *c, int *d, int *resu int *res
A: I have written the code below:
Q: 2. A program that declares and initializes an integer and finds its square root as follows: • If the…
A: 2. The required JAVA code is : import java.io.*;public class Main{ public static void main(String[]…
Q: value) Suppose you save $100 each month into a savings account with an annual interest rate of 5%.…
A: Given: value) Suppose you save $100 each month into a savings account with an annual interest rate…
Q: (Compute e) You can approximate e* using the following series: x? x ex = 1 + 1! 2! 3! 4! n! Write a…
A: PROGRAM CODE: #include <iostream> // include header file for input output…
Q: Assume that N is a positive integer. Returns the sum from 1 to N inclusive, but omitting the numbers…
A: 1. create as set of integer 2. declare temp variable with initial value 0 3. declare i = 0 3. run…
Q: 6.30 LAB: Flip a coin Write a program that simulates flipping a coin to make decisions. The input is…
A: NOTE - This is a Java question, so I have written the code in the Java programming language. Here I…
Q: Q2: Write a program that inputs a five-digit integer, separates the integer into its individual…
A: Below is the implementation of above problem in C++:
Q: Q5/ 1. 1. Write a program to read three marks and calculate the average. If the student's average is…
A: Since no programming language is mentioned, I am using python. As per our guidelines, we are…
Q: QUESTION 2 Write a program that prints out the following pattern **** **** **** ****
A: Required: C++
Q: What will be the values of x and y after the following code is executed? int x = 10, y = 20;…
A: Given, The code in given in C programming language\ Code: int x = 10, y = 20; while (y…
Q: 1- Let's start with some mediationO Print the following pattern on to the screen; uses one printf ()…
A: Algorithm: Start Print the given statements using printf() Read 3 numbers x,y,z Initialize sum to 0…
Q: What is the value of q after the following code executes? int a = 4; int c = 4; int q; if (a > c) {…
A:
Q: 5-3) (Find the highest score) Write a program that prompts the user to enter the number of students…
A:
Q: Question # 8: Write a program that inputs a number and checks whether it is a perfect number or not.…
A: Answer 8: Objective: The program reads the user input and verifies if the number falls under the…
Q: Q5: Ask the user to enter five capital letters (A..Z), and check if the letters are in an ascending…
A: According to the provided information: We need to create a program that will take five capital…
Q: What does the following code segment output? int x= 5; for ( ; ; x++) { if (x < 6) cout<< x << " ";…
A: B. 5
Q: 2.3 Write a Java program that randomly generates three integer numbers between 0-150. Then,…
A: import java.util.*;public class Main{ public static void main(String[] args) { Random rand= new…
Q: 3. Re-write the following program by using switch statement. int main() { int code; cout>code; if (…
A: The given problem is related to C++ programming where the given code has used if-else statement…
Q: Q/Write a program that reads from the user a set of numbers, and first, it has to check how many…
A: Note: Since no programming language is mentioned. I am attempting this in python. if you need it in…
Q: What is the output of the last print statement? def math(x, y): z = x +y print(z) y = math(5, 7)…
A: First of all program execute from main function. calling function call the called function. Called…
Q: 20.5 LAB: Flip a coin Write a program that simulates flipping a coin to make decisions. The input…
A: PROGRAM CODE: # import the required modulesimport random# start the definition of the function to…
Q: Car experts recommend changing your air filter as often as every 6000 miles if the oil’s category is…
A: import java.util.Scanner;class CarDemo{public static void main(String[] args){ int…
Q: E2.7 Write a program that prompts the user for a radius and then prints • The area and circumference…
A: We are going to take radius as input from the user and then we will find out area of the circle,…
Q2: (Financial: Compare cost) Suppose you shop for rice in two different packages. You would like to write a program to compare the cost. The program prompts the user to enter the weight and price of each package and displays the one with the better price.
Here is a sample run:
Enter weight and price for package 1: 50 24.59
Enter weight and price for package 2: 25 11.99
Package 2 has a better price.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- What will be the values of x and y after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; y += 20; } x = _____________________ y = _______________________Output below. You have to codeWhat will be the value of x after the following code is executed? int x = 0; while (x < 50) { x += 20; } 50 20 40 60
- Problem specification: There is a grid of NXN squares. We can easily determines how many different rectangles (squares are excluded) there are in the grid. For example, in a 3X3 grid, you can find 22 different rectangles, marked as the green rectangles. You can see that we did not count the red ones as they are squares. In this assignment, you will write a Java program that takes the value of N as input and determines the total area of all the rectangles in the grid. Assume that the smallest squares in the grid have length 1. So a 3X2 rectangle will have an area of 6. For example, the total area of all the rectangles in the 3X3 grid is 66.…Write a code for the following using Console.WriteLine.Program - python A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consumed in a day. Then, she calculates the number of calories that result from the fat, using the following formula: calories from fat = fat grams x 9. Next, she calculates the number of calories that result from the carbohydrates, using the following formula: calories from carbs = carb grams x 4. Write a program that will make these calculations. Your program should use two separate functions to calculate fat and carb calories. Write a 3rd function that is called from main to capture user input and call the others.
- C++ In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: 74 decimal = 7 x 10^1 + 4 x 10^0 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0). For example: 112 octal = 1 x 8^2 + 1 x 8^1 + 2 x 8^0 Converting an Octal integer into…20.5 LAB: Flip a coin Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the output is either heads or tails. Assume the input is a value greater than 0. Ex: If the input is: 3 the output is: heads heads tails For reproducibility needed for auto-grading, seed the program with a value of 1. In a real program, you would seed with the current time. In that case, every program's output would be different, which is what is desired but can't be auto-graded. Note: A common student mistake is to seed before each call to random.randint(). But seeding should only be done once, at the start of the program, after which random.randint() can be called any number of times. Your program must define and call the heads_or_tails() function that randomly picks 0 or 1 and returns "heads" or "tails". Assume the value 0 represents "heads" and 1 represents "tails". this is what i have import randomdef heads_or_tails(n): i=0 while…20.5 LAB: Flip a coin Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the output is either heads or tails. Assume the input is a value greater than 0. Ex: If the input is: 3 the output is: heads heads tails For reproducibility needed for auto-grading, seed the program with a value of 1. In a real program, you would seed with the current time. In that case, every program's output would be different, which is what is desired but can't be auto-graded. Note: A common student mistake is to seed before each call to random.randint(). But seeding should only be done once, at the start of the program, after which random.randint() can be called any number of times. Your program must define and call the heads_or_tails() function that randomly picks 0 or 1 and returns "heads" or "tails". Assume the value 0 represents "heads" and 1 represents "tails". Use Python, please.
- IN PYTHON PLEASE AND FLOWCHART DRAWING COPUTERIZED PLEASE!! In many businesses across the country, people are buying food and goods using cash. Whenever a purchase is made with cash, it is usual that change must be back to the customer. Business point of sales software help to ensure that the correct change is return to a customer by providing detailed information of the change that should be returned to the customer. using the fewest number of bills and coins. In this assignment, you are asked to design and implement a program that writes out what bills (ones, fives, tens, twenties) and coins (pennies, nickels, dimes, and quarters) that should be returned to the customer given two inputs from the user: A total cost of a sale. The amount that was paid by the customer. Ensure that your output is grammatically correct. If the customer does not provide adequate payment, you should print the following statement, the program should end. Did not receive enough cash from the customer.…Consider the following statement:int* p, q;This statement could lead to what type of misinterpretation?-scripting language Write a program that randomly generates a lottery between 100 and 999 (random.randint(100, 999)), prompts the user to enter a number in the same range, and determines whether the user wins according to the following rule: (1) If the user input matches the lottery in exact order, print "the award is $10,000". E.g., lottery = 123, input = 123(2) If the user input matches the lottery, but in wrong order, print "the award is $6,000". E.g., lottery = 123, input = 321(3) If two digits in the user input matches a digit in the lottery, print "the award is $3,000". E.g., lottery = 123, input = 612(4) If one digit in the user input matches a digit in the lottery, print "the award is $1,000". E.g., lottery = 123, input = 289(5) If none of the digits is matched, print "thank you".