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
- Coin Exchange: Write a program that will determine how many coins of each denomination (50kr, 25kr, 10kr, Skr, and 1kr) are required to make up a given amount of change. For example, to make 57kr we could use 1 x 50kr, 1 x 5kr, and 2 x 1kr., It should be obvious that many combinations of coins are possible. For example, in the example above, we could make up 57kr with: (57 x 1kr) or (2 x 25kr and 7 x 1kr). However, your program must use the smallest number of coins (10 points). Example program output: Enter amount: 40 40 Kr = 1 x 25Kr 1х 10Кr 1 x 5KrSimulate the dice game of lucky sevens. The rules are: roll two dice if the sum equals 7, win $4 if the sum is not 7, lose $1 Write a program that asks the user how much they would like start the game with. The program should then: simulate the dice roll (using the random function) and show what was rolled show what the user’s funds are after each roll ask the user if they want to roll again if the user wants to roll again, repeat the three actions above if the user does not want to roll again give some response and end the game the final output should show if they won or lost money, and how many rolls they playedAssignment Write a program that moves a forester unit and a desert corps unit to a given target location and prints the number of hours it took for each unit to reach the target. First, the user will give the starting X and Y positions of the forester unit as well as its base speed (all ints). Then, the starting X and Y positions of the desert corps unit as well as its base speed (all ints). Finally, the target X and Y positions (both ints) and the terrain type (std::string). Speeds are given as distance traveled in one full day (i.e., 24 hours) and is affected by the terrain type using a multiplier over the base speed. Also, after 1 full day, each unit rests for a certain number of hours. Speed multiplier and rest amount of each type of unit depending on the terrain type are as below. Speed Multiplier Rest Duration After 1 day Terrain type Forester Desert Corps Forester Desert Corps Forest 1.3 0.6 4 12 Desert 0.4 1.2 15 6 Hills 0.7 0.8 6 8 Others 1.0 0.8 8 6 After getting all this…
- 4- Write a program that reads the average of 30 students and find the number of pass students , the number of fail students then print the results. 5- Write a program that reads 20 numbers then find the number of negative and positive numbers and the number of numbers equal to zero and print the results. 6- Write a program to read three numbers A,B,C then find whether A,B,C can form the sides of a triangle, if yes compute the parameter of the triangle , if no print the massage ( not a triangle), then determine whether A,B,C form the side of an (a)) equilateral triangle ,b) isosceles triangie ,c)) right angle triangle Hint: ( A,B,C can form a triangle if each side is less than the sum of the other two sides)2. Party shop sells birthday gift bags in two ways. set of 12 bags for $17.99 or an individual bag for $1.75. Customers can purchase a Write a complete program that asks the user input for the number of gift bags need to be purchased (an integer) and outputs the total price of the purchase. a) For example, if the customer buys 14 gift bags, the customer would be charged for 1 set of (12 bags) plus another 2 individual bags. The subtotal would be 1 (17.99) + 2 (1.75) = $21.49. b) Use a constant variable to set a fixed tax rate of 8.875. c) Display correct dollar values (2 decimal places, use cout precision). User input can be any content and it's bold and italicized for clarity. Example Output 1 Welcome to Party Shop! How many gift bags would you like to purchase: 14 SHOPPING CART 1-set (s) $17.99 2-individual $3.50 Subtotal: $21.49 Таx: $1.91 Total: $23.40 Thank you shopping Party Shop! Example Output 2 Welcome to Party Shop! How many gift bags would you like to purchase: 11 SHOPPING…Summary When you borrow money to buy a house, a car, or for some other purposes, then you typically repay it by making periodic payments. Suppose that the loan amount is L, r is the interest rate per year, m is the number of payments in a year, and the loan is for t years. Suppose that i = (r / m) and r is in decimal. Then the periodic payment is (first image which R=....): You can also calculate the unpaid loan balance after making certain payments. For example, the unpaid balance after making k payments is (second image which L'=....) : where R is the periodic payment. (Note that if the payments are monthly, then m = 12.) Instructions Write a program that prompts the user to input the values of L, r, m, t, and k. The program then outputs the appropriate values. Your program must contain at least two functions, with appropriate parameters, to calculate the periodic payments and the unpaid balance after certain payments. Make the program menu driven and use a loop so that the…
- TASK " Write a program that grades students' exam. The exam has 20 multiple choice questions. Here are the correct answers: 1- A 6- B 11-C 16- D 2- A 7- B 12- C 17- D 3- А 8- В 13-С 18- D 4- А 9- В 14- С 19- D 5- A 10-B 15- C 20- D "A student must correctly answer 15 of the 20 questions to pass the exam. " Write a class named StudentExam that holds the correct answers to the exam in an array. TASK (CONT.) " The class should also have an array that holds the student's answers. The class also should have the following methods: I passed. Returns true if the student passed the exam, or false if the student failed " totalCorrect. Returns the total number of correctly answered questions I totallncorrect. Returns the total number of incorrectly answered questions " questionsMissed. An int array containing the question numbers of the questions that the student missed. 1 On another class, ask the student to enter his name, take his answers and display the results returned from the StudentExam…Problem: A company wants a program that will calculate the weekly paycheck for an employee based on how many hours they worked. For this company, an employee earns $20 an hour for the first 40 hours that they work. The employee earns overtime, $30 an hour, for each hour they work above 40 hours. Example: If an employee works 60 hours in a week, they would earn $20/hr for the first 40 hours. Then they would earn $30/hr for the 20 hours they worked overtime. Therefore, they earned: ($20/hr 40hrs) + ($30/hr 20 hrs) = $800 + $600 = $1400 total. For this assignment, you must create pseudocode and a flowchart to design a program that will calculate an employee's weekly paycheck. . Write pseudocode to design a programming solution by outlining a series of steps and using appropriate indentation and keywords. As you write your pseudocode, be sure to consider the following: What input does the computer need? What steps does the program need to follow to process the input? What output should…Exercise 4: Write a program that reads two pieces of information: the hourly wages and the number of hours worked by the employee. The program should then calculate the net salary of the employee and display the results as shown in Figure 4. Note that: the net salary of the employee is the sum of the basic wages (which is number of hours worked times the hourly wages) minus the Social Security fees; where the Social Security fees represent 10% of the Basic wages. Name your program Lab3_Id_ex4.py, where Id is your university Id. Include the design of your solution as comments at the beginning of your program. Test your solution with different input data. Please enter the employee hourly wages? 10 please enter the number of hours worked? 40 Basic Salary Hourly Wages Number of Social Net Salary Hours Security **** 10.000 40.00 400.000 40.000 360.000 **** Figure 4: Exercise 4 Sample Run
- 1. Write a program that prints your full name. Write a program that prints your full name using asterisk(*). Write a program that prints a square, a rectangle and a triangle using asterisk. Write a program that adds THREE(3) numbers. Write a program that multiply THREE(3) numbers. Write a program that divides TWO(2) numbers.In python, a) In the Hi-Lo game, the player begins with a score of 1000. The player is prompted for the number of points to risk and a second prompt asks the player to choose either High or Low. The player’s choice of either High or Low is compared to a random number between 1 and 13, inclusive. If the number is between 1 and 6 inclusive, then it is considered “low”. A number between 8 and 13 inclusive is “high”. The number 7 is neither high nor low, and the player loses the points at risk. If the player had guessed correctly, the points at risk are doubled and added to the total points. For a wrong choice, the player loses the points at risk. Create a HiLo application based on this specification. Application output should look similar to b) Modify the application to allow the player to continue until there are 0 points left. At the end of the game, display the number of guesses the user took before running out of points.Part 1: Complete the survey. Part 2: Peek-a-boo is a fun game that little kids like to play. To simulate this game on the computer, write a program that will generate a random number between 1 and 4. Then, will print to the screen the animal name associated to that number. The animal names used will be: pig when a 1 is generated cow when a 2 is generated chicken when a 3 is generated horse when a 4 is generated If your program generates a 3, the output will be: chicken The player will then enter a 1 if they would like to play again or anything else to exit the program. If the player enters "1 1 1 0", the output will be: horse chicken cow horse For coding simplicity, follow each output animal by a space, even the last one. Hint: To make testing easier, seed your random number generator with 0.