21. The five line bellow are used to determine the profit or loss of a sale based on the buying cost and selling result after a margin calculation. The correct order of the program is. 1n = int (input () ) 2 buycost - 1000 + n + 1000 3 sellResult 1200 • n 4 if (sellPrice-buyPrice>0) : profit = True 6 if (sellPrice-buyPrice<=0) : profit = False a. 1, 2, 3, 4, 5. no line of code can be reversed b. 1. 2. 3, 4. 5. with line-1, line-2, line-3 can be reversed each other c. 1, 2, 3, 4, 5. with line-4 and line-5 can be reversed with line-6 and line-7 d. Line-4 untul line-7 must be in sequence but can be placed in any order
Q: Q2: Write a program in C++ to read ten students' name and degrees then calculate the average degree…
A: The program has to be designed as follows: Create arrays for storing names of students. Create…
Q: C++ Programming The Card Game One day, Fred and his N friends were playing a card game in which each…
A: Required: We have to write a code to maximize the sum which we get on the front cards, keeping in…
Q: 6. A microwave oven manufacturer recommends that when heating two items, add 50% to the heating…
A: Hey, since multiple questions posted, we will answer first question according to our policy. If you…
Q: Implement the following decision table using a nested if statement and multiple alternatives if…
A: When the grade point average value lies between 1.0-1.99 (inclusive both the values) or not. If yes…
Q: 4.20 LAB: Warm up: Automobile service cost (1) Prompt the user for an automobile service. Output…
A: In this first of all user get the menu of automobile services then user has to input which service…
Q: An employee is paid at a rate of $16.78 per hour for regular hours worked in a week. Any hours that…
A: Program Explanation: 1) Here are input and output methods that are to be used. 2) Use the access…
Q: Display basic salary, bonus and net salary
A: EXPLANATION--> Firstly input two variable named with salary and grade If grade is greater then…
Q: b) Write a full program by apply the following decision table using nested if statement. Assume that…
A: Sample Response: //C++ programming language#include <iostream>using namespace std;//main…
Q: Write a C++ program. A software company sells a package that retails for $109. Quantity discounts…
A: To write a C++ program using the if/else if/else statement that asks for the number of units sold…
Q: 6.25 LAB: Flip a coin c++ Write a program that simulates flipping a coin to make decisions. The…
A: string HeadsOrTails() { int x = rand(); if(x % 2 == 0) { return "heads"; } else { return "tails";…
Q: 4. Write a program that simulates the rolling of two dice. The program should use rand twice to roll…
A: Code: #include <stdio.h>#include <stdlib.h>#include <time.h> int main(){ int…
Q: C++ Programming The Card Game One day, Fred and his N friends were playing a card game in which each…
A: Algorithm: 1. First calculate the total sum of the input array as total_sum and store it. 2. Iterate…
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: CHALLENGE 2.1.1: Reading multiple data types. ACTIVITY Type two statements. The first reads user…
A: 1) Take input into variable using input() function 2)default input() function takes input as string…
Q: Suppose you have a certain amount of money in a savings account that earns compound monthly…
A: Here I have created a function that takes 3 input parameters, compute the future value and return…
Q: Example 1: Write a C++ program to read student's mark and print "passed" if it is greater than 50.…
A: #include<iostream>using namespace std;int main(){ int mark; cout<<"Enter student's mark:…
Q: Using Java programming language write a program to manage a hotel with 24 rooms; 10 rooms are…
A: It is defined as
Q: 1. A software company sells a package that retails for $99. Quantity discounts are given according…
A: logic:- take quantity as user input. apply if else to find out discount. at last subtract…
Q: C# Programming The Card Game One day, Fred and his N friends were playing a card game in which each…
A: Required: We have to write a code to maximize the sum which we get on the front cards, keeping in…
Q: Q1. Write a program in which the output of the program should be the performance result of a student…
A: Program description: n is the user input integer variable that is used to take from the user the…
Q: A student took four quizzes in a term and would like to compute their average. He also would like to…
A: 1. Input marks of 4 quiz 2. Add the marks of 4 quiz to get the total(tot) 3. Divide the add value…
Q: 5. Write a program that determines the change to be dispensed from a vending machine. An item in the…
A: The program accepts the input value to a variable. It declared other variables for storing the…
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: 1. Write a simple program to determine the credit card types according to annual income and user…
A: #include <iostream> using namespace std; int main(){ int inc,interest;…
Q: Program33.java Write a program that generates a random Fahrenheit oral temperature between 92 and…
A: To generate a random number, Random class is used in java util library. nextInt(bound) method…
Q: C# Programming The Card Game One day, Fred and his N friends were playing a card game in which each…
A: Given:
Q: C++ Programming The Card Game One day, Fred and his N friends were playing a card game in which each…
A: Required: We have to write a code to maximize the sum which we get on the front cards, keeping in…
Q: Problem 4. Write a program that will accept the tuition fee and compute the total tuition fee based…
A: Accept tution fee as integer and then find the total amount and the convert to integer and display…
Q: Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats)…
A: Here I have created the function named driving_cost(). In this function, I have divided the miles by…
Q: PROGRAM DESCRIPTION Make a program that accept employee number, employee name, job code (A/B/C) and…
A: First, we will input the name, job code, number, and hours worked. Based on Job code and hours…
Q: Write a program to check whether the message received at the destination is error-free. For…
A: Algorithm 1. Declare variable length1 and length2 to record length of both the sequence 2. Start…
Q: 10. Let p be the statement “He gets frustrated.” and q be the statement “He will be able to complete…
A: Here in this question we have given a logical statement and we have asked to convert into english…
Q: A business law class of 25 students takes a midterm exam that has 100 true- or-false questions. The…
A: We need four arrays in this problem. The array KOUNT stores the number of times a grade is achieved…
Q: Q3. Write a payroll program using following rules: Hourly rate: ask user - If an employee works 40…
A: Sample Response: //C++ program to calculate total pay#include <iostream>using namespace std;…
Q: Write a program that will read an executive's job number, level number, and basic pay and then…
A: #define CA1 1000#define CA2 750#define CA3 500#define CA4 250#define EA1 500#define EA2 200#define…
Q: Part B In C++, if the statement ( int a=5, b=2; ) is written at the beginning of the program, then…
A: As per our guideline simple questions are present in a single image, supposed to solve only three…
Q: 8. Write a program that calculates and displays a person's body mass index (BMI). The BMI is often…
A: Input weight, height Calculate BMI Use if conditional statements to check the person condition based…
Q: Apply your knowledge of Computer Programming to solve the following problem: Write a complete…
A: printf("\nEnter Customer Type:\nM for member\nC for card holder\nL for lucky draw winner\nEnter…
Q: 8. Write a program that will determine the salary of an employee based on his or her rank as…
A: Note: since programming language is not mention , we are providing solution in c++ . please repost…
Q: C# Programming The Card Game One day, Fred and his N friends were playing a card game in which each…
A: Required: We have to write a code to maximize the sum which we get on the front cards, keeping in…
Q: Craps. Here are the rules for a pass bet in the game of craps: Roll two 6-sided dice, and let x be…
A: Python Code: import random# Returns the value of a simulated roll of two dicedef roll_dice():…
Q: 1. Write a program to play rock-paper-scissors. The program should let the user determine whether it…
A: from random import randint #create a list of play optionst = ["Rock", "Paper", "Scissors"] #assign a…
Q: An Auto Insurance Program Example - Write a C++ program to determine the cost of an…
A: PROGRAM: //Header File #include <iostream> using namespace std; //Defining main int main() {…
Q: Q4. Write a program that calculate the person's Body Mass Index (BMI). The BMI is often used to…
A: Given: Write a program that calculates and displays a person’s body mass index (BMI). The…
Q: Suppose we add $100 to a checking account in year 1, $200 in year 2, $300 in year 3, and so on. The…
A: #include <iostream>using namespace std; int main(){ double balance = 0; int year = 0;…
Q: Problem #2: [50 pts] Write a program that calculates the net salary after tax deduction according to…
A: Code and output is given in step2
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: C++ Programming The Card Game One day, Fred and his N friends were playing a card game in which each…
A: Required: We have to write a code to maximize the sum which we get on the front cards, keeping in…
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Step by step
Solved in 3 steps with 2 images
- Summary Interest on a credit card's unpaid balance is calculated using the average daily balance. Suppose that netBalance is the balance shown in the bill, payment is the payment made, d1 is the number of days in the billing cycle, and d2 is the number of days payment is made before billing cycle. Then, the average daily balance is: averageDailyBalance = (netBalance * d1 payme If the interest rate per month is, say, 0.0152, then the interest on the unpaid balance is: interest averageDailyBalance * 0.0152 Instructions Write a program that accepts as input netBalance, d1, payment, d2, and interest rate per month ( interestRate).An Auto Insurance Program Example - Write a program to determine the cost of an automobile insurance premium, based on driver's age and the number of accidents that the driver has had. The basic insurance charge is 500 Rs. There is a surcharge of 100 Rs if the driver is under 25 and there is an additional surcharge for accidents as can be seen below: No. of accidents Accident Surcharge 1 50 2 125 3 250 4 375 5 575 6 or more No insuranceAn Auto Insurance Program Example - Write a program to determine the cost of an automobile insurance premium, based on driver's age and the number of accidents that the driver has had. The basic insurance charge is 500 Rs. There is a surcharge of 100 Rs if the driver is under 25 and there is an additional surcharge for accidents as can be seen below: No. of accidents Accident Surcharge 1 50 2 125 3 250 4 375 5 575 6 or more No insurance Note: Use switch cases when you check the total number of accidents.
- Interest on a credit card’s unpaid balance is calculated using the average daily balance. Suppose that netBalance is the balance shown in the bill, payment is the payment made, d1 is the number of days in the billing cycle, and d2 is the number of days payment is made before billing cycle. Then, the average daily balance is: averageDailyBalance = (netBalance * d1 – payment * d2) / d1 If the interest rate per month is, say, 0.0152, then the interest on the unpaid balance is: interest = averageDailyBalance * 0.0152 Instructions Write a program that accepts as input netBalance, d1, payment, d2, and interest rate per month (interestRate). The program outputs the interest. Format your output to two decimal places. Input: 100 30 50 7 9.7 Output: 856.83 Test case 2: Input: 255.76 31 55 3 12.3 output: 3080.38Interest on a credit card’s unpaid balance is calculated using the average daily balance. Suppose that netBalance is the balance shown in the bill, payment is the payment made, d1 is the number of days in the billing cycle, and d2 is the number of days payment is made before billing cycle. Then, the average daily balance is: averageDailyBalance = (netBalance * d1 – payment * d2) / d1 If the interest rate per month is, say, 0.0152, then the interest on the unpaid balance is: interest = averageDailyBalance * 0.0152 Write a program that accepts as input netBalance, d1, payment, d2, and interest rate per month (interestRate). The program outputs the interest. Format your output to two decimal places.Interest on a credit card’s unpaid balance is calculated using the average daily balance. Suppose that netBalanceis the balance shown in the bill, paymentis the payment made, d1is the number of days in the billing cycle, and d2is the number of days payment is made before the billing cycle. Then the average daily balance is: averageDailyBalance = (netBalance * d1 –payment * d2) / d1 if the interest rate per month is say, 0.0152, then the interest on the unpaid balanceis: interest = averageDailyBalance * 0.0152 Design a program that accepts as input netBalance, payment, d1, d2, and interest rate per month. The program outputs the interest charged. Format your output to two decimal places. C++
- Problem D: Different Dice Game Consider the following game for two players: The first player rolls a pair of dice of fair six-sided dice. If the two dice show different numbers, the player's score is the larger of the two numbers. Otherwise, the player's score is the sum of the two numbers. At this point, the player is asked if they want to remove their lower die and re-roll one die. If they say no, the player keeps her score and their turn is over. If they say yes, then they roll one more die and the number showing on this die replaces the lower of the original two rolls. Then these two dice rolls are scored accordingly. (For example, if the initial roll was a 2 and 5, if the player doesn't roll again, she gets 5 points. If she does roll again and obtains a 4, her score is still 5. If she rolled again and obtained a 6, her score would be a 6. If she rollwed again and obtained a 5, her score would be a 10.) The second player goes after the first, doing the exact same steps as the first…Problem 2: Employee Payment The Stark Industry needs a program to calculate how much to pay their hourly employees. They have the following rules: An employee gets paid (hours worked) × (base pay), for each hour up to 40 hours. For every hour over 40, they get overtime = (base pay) × 1.5. If the number of hours is greater than 60, print an error message. Example: If an employee works for 45 hours, and his base pay is $8 , the he will get= (40 * 8)+ [5* (8 * 1.5)] = $380 Create a new class called StarkIndustry. Write a method that takes the base pay and hours worked as parameters, and prints the total pay or an error. Write a main method that calls this method for each of these employees: Employee No Base pay Hours Worked Employee 1 $7.20 35 Employee 2 $8.20 47 Employee 2 $10.50 73 You will have to submit StarkIndustry.java file.Problem Description: In the Whimsical Library, each book is enchanted with a magical code to ensure the protection of knowledge. The validation process for these magical codes involves a combination of mathematical spells. The validation process is described as follows: Take the sum of the digits at odd positions from left to right. Take the sum of the squared digits at even positions from left to right. If the absolute difference between the results from step 1 and step 2 is a prime number, the book code is considered valid; otherwise, it is invalid. Example 1: Consider the magical book code 86420137. Step 1. Take the sum of the digits at odd positions from left to right. 8+4+0+3=15 Step 2. Take the sum of the squared digits at even positions from left to right. 6^2+2^2+1^2+7^2=36+4+1+49 = 90 Step 3. If the absolute difference between the results from step 1 and step 2 is a prime number. 115-901 75 (not a prime number) Book code 86420137 is invalid. Example 2: Now, let's examine the…
- Assignment Write a program that tracks how much steps the user walks in total in a day and reports if the daily target is reached or not. The program will keep reading double values, each representing steps walked during an individual activity within a day (stepsWalked) until either the user enters a negative value or the daily target of 5000 steps is met. If the user enters a negative number, the program should print total steps walked as a double. Otherwise, if the target is exactly reached, the program should simply print "Target is reached", finally if the target is surpassed the program should print the text "Target is surpassed by", followed by the excess amount above the target as a double, and finally printing the text "steps". NOTE: You MUST use a repetitive statement in this question. NOTE: Each stepsWalked value will be given as a non-negative value. You do NOT need to check this. Input Output Answer assignment 3000 1300 500 2305.2 Target is surpassed by 2105.2 steps 450…When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first months interest on $1,000 is 1000 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 6 = 19. This means after making the first payment, the loan amount is 1,000 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 5.89 = 19.11 and the remaining balance after the second payment is 981 19.11 = 961.89. This process is repeated until the loan is paid. Write a program that accepts as input the loan amount, the interest rate per year, and the monthly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first months interest, then after each payment, the loan amount will increase. In this case, the program must warn the borrower that the monthly payment is too low, and with this monthly payment, the loan amount could not be repaid.)Question Using Java programming language write a program to manage a hotel with 24 rooms;10 rooms are Executive, with price Gh ₵ 2500.00 per night,7 rooms are Chalets, with amounts Gh ₵ 1500.00 per night7 rooms are Ordinary, with amount Gh ₵ 500.00 per night The program should allow customers to book for rooms for a number of nights, and update the number of empty rooms available for each category when a customer has paid fully and has checked-in; also update the number of empty rooms available when customer checks-out.Customers should make bookings with their first names, telephone number A customer should be prompted to know if a room is booked (meaning a another customer has booked it but has not paid fully, or has not checked-in) A customer should be prompted to know if a room is occupied (meaning a booked room has been fully paid for, or the customer has checked-in) A customer should be prompted to know if a room is available (meaning a room has neither been booked nor…