c) Write a program for the following problem by using for statement: Ahmad saves RM1000 in his account in a bank which returns 5% of annual interest. Assuming that all interests is left deposited in his account, calculate and print the amount of money in his account at the end of each year for 10 years by using for loop. Use the following formula to determine these amounts: a = p(1+r)" Where; a = the amount of deposit at the end of nth year p = original amount saved r = annual interest rate n = number of year
Q: Write a single C statement to accomplish each of the following: d) Calculate the remainder after q…
A: Step 1:- Program Approach:- 1.Include header file 2.Declare variables 3.Take the input from the…
Q: Q1/ Write a program to print multipliers of 5 (from 5 to 50). (Using Do until statement)
A:
Q: 3) Write a general program that computes the values e by using the following equation. Calculate the…
A: C++ code for the given problem :- #include <iostream>#include<math.h>using namespace…
Q: 18. Write a program that will display the following pattern, given the Example: If n =5, output…
A: C code to print given pattern is as below.
Q: Let X and S denote any valid C++ expressions. Then, the below statement is equivalent to: do (X}…
A: The given requirement is to select one correct answer from the given options a,b,c,d and e . The…
Q: QS: A/ Use input function to write a computer programming to test the weather state according to a…
A: #include <iostream> using namespace std; void checkWeather(int); int main(){ int…
Q: Q2: Write C program to find and display the value of X in the following equations: X = 7Y + A²
A: Here is Your Code #include <stdio.h>#include<math.h> int main(){ int x,y=2,a=4; x…
Q: The following statement should determine if x is not greater than 20. What is wrong with it?
A: Answer: Given statement error is highlighted with red font if (!x>20)
Q: 15. Consider the following program that attempts to compute the circumference of a circle given the…
A: Program Code: #include <iostream>using namespace std; #define PI 3.141 int main(){ float…
Q: Type two statements. The first reads user input into person_name. The second reads user input into…
A: Here, Code instructions are given.
Q: Write C++ statements that accomplish the following. (6, 7) а. Declare int variables x and y.…
A: Please find the answer below
Q: Assignment 3: Write a program to calculate the following: B=£x*
A: Algorithm/Steps: Ask the user to the input the value of n Store sum in variable B calculate the sum…
Q: Q.2/ Write a program to enter a value of x and compute the value of y x if x20 |-x if x<0 where y =
A: Task :- Write a program according to the given function.As programming language is not specified,…
Q: 1. Write a function which takes an input 'n' and calculates the sum of the first n natural numbers…
A: The requested Matlab program is provided in the next step by using a for loop and function.
Q: Question 2: Ali gives pocket money to his son in following fashion. Whatever pocket money is given…
A: Include the required libraries in the program. Declare the main function. Declare the variables of…
Q: 1. Write a c++ programto calculate the parking fare for customerswho park their carsin parking lot…
A: Explanation: type_of_vehicle, hours and minutes are the variables used to store data by user. Then…
Q: Using Function loading a) Make a list of five diseases and their respective treatment. Enter your…
A: Need to write C++ program using function loading It should have list of five disease with their…
Q: 28. If originally x=4, what is the value of x after the evaluation of the expression: x+=4
A: Given, x = 4. The value of x after the evaluation of the expression: x+=4 is 8.
Q: Q2: Write a program to compute and display a person's weekly salary as determined by the following…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Read no.of hours n…
Q: 8) Find the final value of a ,y and v. Assume v = 6, k = 4.5 and y = 3 a = (int)k * y; y = ++a * v;…
A: As per our guidelines we are allowed to answer only first question.pleae post question separatly.
Q: In Python Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon…
A: def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon):…
Q: Exercise 3: Write a C++ program that asks the user to enter the value for input variables, and…
A: Given that Write a c++ program that asks the user to enter the value for input variables, and…
Q: Q3: Write a VB program to enter a mark of a student and then find his grade as If mark >=75 print…
A: Algorithm 1.create one module name is marks 2.enter student name marks 3.calculate total marks…
Q: 2.14 LAB: Expression for calories burned during workout The following equations estimate the…
A: as per Bartleby guidelines we are supposed to answer?️ only one question. Kindly repost other…
Q: Q5.Write C++ program to compute and display a person's weekly salary as determined by the following…
A: Objective: A program should be written to calculate a person's weekly salary when the number of…
Q: A certain company offers seven annual salary levels (dollars): 12000, 15000, 18000, 24000, 35000,…
A: Hey there, I am writing the required solution for the above stated question . Solution of the above…
Q: 16. Write a program that will display the following pattern, given the value of n and m. Example if…
A: We have to write a C program to print the pattern as given. Here n (number of columns) and m (number…
Q: Write a function ascii_name_plaque (name) which takes as input a string representing the name of a…
A: Coded using Python 3.
Q: 2. Write a program to input a number x from the keyboard. If the number is larger than 0, find its…
A: The problem is based on finding the square or square root of a number depending on its value.
Q: user-defined function and appropriate conditional and looping statements, create a program using C++…
A: Explanation: Detail Code #include <bits/stdc++.h>using namespace std; int main(){ int…
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: Exercise 5: Write a C++ program that asks the user to enter the value for input variables, and…
A: The c++ code along with the output for division operation has given is step 2.
Q: Q1: Write a program to compute the following equation (Y=5x2 + 2), when the .input values greater…
A: For question 1 the answer is the following code : #include<stdio.h>#include<conio.h>…
Q: Q2/ Write a program to express the equation below: x²_y³ z* = A 6. 4 3 And find the A value if x = 5…
A: SOLUTION : As the equation and data is given in the question. Find the A value: x=5 ,store at DS…
Q: 3) Write a general program that computes the values e" by using the following equation. Calculate…
A: Actually, program is a executable software that runs on a computer
Q: E Expert Q&A Please read the questions carefully before answering and also your answers must be in C…
A: Given :- Please read the questions carefully before answering and also your answers muste in C ++…
Q: 6. Write a program to read a number representing the time in 24-hours (i.e., 4-digits ). Then find…
A: import java.text.SimpleDateFormat;import java.util.*;import org.apache.commons.lang3.time; class…
Q: Using user defined function and appropriate conditional and looping statements, create a program…
A: CODE:- #include<iostream>using namespace std;int payment(int tot){ int paym; do{…
Q: Write C++ program to compute and display a person’s weekly salary as determined by the following…
A: #include <iostream>using namespace std;int main(int argc, char const *argv[]){ int workHours;…
Q: 13. Write a program that will display the following pattern, given the Example: If n = 4, output…
A: codE: #include <iostream> using namespace std; int main(){ int i, j, rows; printf("Enter…
Q: Write two fragment of code in C++ using while and do..while loop respectively that repeatedly prompt…
A: Your C++ program is given below as you required with an output.
Q: Write a program calculating the area of a triangle with the length of the three sides as a, b, c,…
A: Task :- Write a program to calculate the Area of given triangle . C++ program :- #include…
Q: SHI Hospital provides top-notch medical care with comfortable rooms, The following are the types of…
A: Algorithm: Start Read patient name, room name, no.of days spent n, whether used critical care units…
Q: Problem 2. (Playing the Waltz) Write a program called playwaltz.py that accepts from standard input,…
A: Write a program playvalt2.py that accepts from standard input, a sequence of 32 integers…
Q: 3. Write a computer program to solve the quadratic equation below: ax²+ bx + c = 0 The input data is…
A: Program: Programs are used to solve complex problems. The main objective of the program is…
Q: 2.21 LAB: Expression for calories burned during workout The following equation estimates the average…
A: Find the required code in java given as below and output :
Q: Write a program that accepts dates written in numerical form and outputs in complete form. Enter…
A: here in question In this c code, there are 3 variables m, d, and y for storing month, day, and year.…
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: Write true if the two statements are equivalent; otherwise write false. (p∨∼q) ∨q and p
A: Here in this question we have given two statement and we have asked to write true if they are…
Step by step
Solved in 2 steps with 1 images
- Use C++ 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 tails heads For reproducibility needed for auto-grading, seed the program with a value of 2. 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 call srand() before each call to rand(). But seeding should only be done once, at the start of the program, after which rand() can be called any number of times. Your program must define and call the following function that returns "heads" or "tails".string HeadsOrTails()Numerical analysis) Given a number, n, and an approximation for its square root, a closer approximation of the actual square root can be found by using this formula: newapproximation=(n/previousapproximation)+previousapproximation2 Using this information, write a C++ program that prompts the user for a number and an initial guess at its square root. Using this input data, your program should calculate an approximation of the square root that’s accurate to 0.00001. (Hint: Stop the loop when the difference between the two approximations is less than 0.00001.)17. Redo Programming Exercise 16 so that the user can also input the cost of producing one liter of milk and the profit on each carton of milk.
- Programming Practice a) Write a program which allows a teacher to determine the min, max, and average grade from grades entered. The teacher will continuously enter grades until the sentinel is specified. For this example, a grade of -1 will be used to denote grading is completed. The min, max, and average grade should then be displayed to the teacher. This program should not accept invalid grades to be used [0, 100]. b) Write a program which outputs prime numbers up to a specified number. For example, if a user entered the number 25, the program would output the prime numbers between 1 and 25. c) Write a program which converts a sum of currency into the highest available denominations in terms of coins. For example, the user inputs the number 4.25. The program would output that it takes 2 Toonies and 1 Quarter. Ensure that the result uses the least amount of coins possible. This can be solved mathematically or using loops.Write a C++ (use cout and cin )program that calculates a student's GPA. Ask the user to enter grade and also the credit hours of the course in a loop until user enter “N” or “n”. Earned points in that course becomes Grade point * credit hours i.e., Earned points = Grade point*credit hours Grade points of each grade are as follows Grade Grade Points A = 4 B = 3 C = 2 D = 1 F = 0 Example: You got “A” grade in Computer Programming theory course and the credit hours are 3. So your earned grade points=4*3=12 Similarly if you get “C” grade in another subject e.g., Computer Fundamentals and the credit hours are also 3 here. Now earned grade points = 2*3=6 If you get “B” grade in Circuit and Systems theory and the credit hours are 3. So your earned grade points=3*3=9 Now your GPA = (12+6+9) / 9 = 3C++ Programming Exercise: A real estate office handles, say, 50 apartment units. When the rent is, say, $600 per month, all the units are occupied. However, for each, say, $40 increase in rent, one unit becomes vacant. Moreover, each occupied unit requires an average of $27 per month for maintenance. How many units should be rented to maximize the profit? Write a program that prompts the user to enter: a. The total number of of units. b. The rent to occupy all the units. c. The increase in rent that results in a vacant unit. d. Amount to maintain a rented unit. The program then outputs the number of units to be rented to maximize the profit.
- In C have the user enter their beginning principal balance (must be a float greater than zero).If not a float greater than zero, have the user enter again. (Use a do-while loop)Have the user enter their desired annual interest rate (must be a float greater than zero and less than 15%).If not a float greater than zero and less than 15%, have the user enter again. (Hint: Use a do-while loop)Have the user enter their desired number of quarters (must be an integer greater than zero or less than orequal to 44).If not an integer greater than zero and less than or equal to 44, have the user enter again. (Hint: Use a do-while loop)Display all of the information entered in steps 1-6 as seen in the display window below..Ask the user if all of the values are correct. If yes, proceed with step 9. If no, return to step 1. (Hint: Use ado-while loop)For each quarter, calculate and display the beginning principal balance, the interest earned, and the finalprincipal balance for the quarter using a for…Display the first N magic numbers, where N is a positive number that the user provides as input. Here, a magic number is a number whose sum of its digits eventually leads to 1. For example, 1234 is a magic number because 1 + 2 + 3 + 4 = 10 and 1 + 0 = 1, while 1235 is not (1 + 2 + 3 + 5 = 11 and 1 + 1 = 2). Write a program that prints out the first N magic numbers, seven on each line. You are required to use the following function prototype: bool isMagic(int value); // Returns true if value is a magic number The outline of this function will be as follows: Step 1: Calculate the sum of digits of the value Step 2: Repeat Step 1 until we get a single-digit Step 3: If the resulting sum is equal to 1 then it is a magic number, otherwise not Here is the sample output:Modify the craps program to allow wagering inside of C#, and explain each step (reject if you can't). Initialize variable Balance to 1000 dollars. Prompt the player to enter a wager. Check whether the wager is less than or equal to Balance and, if not, have the user reenter the wager until a valid wager is entered. After a valid wager is entered, run one game of craps. If the player wins, increase Balance by wager, and print the new Balance. If the player loses, decrease Balance by wager, print the new Balance, check whether Balance has become zero and, if so, print the message “Sorry. You busted!” (explain steps as much as possible so I can understand plz).The program to modify has the code listed below:// Craps class simulates the dice game craps.using System; class Craps{// create random-number generator for use in method RollDiceprivate static Random randomNumbers = new Random(); // enumeration with constants that represent the game statusprivate enum Status {Continue, Won, Lost}…
- 1.Write program to iteratively compute Fibonacci numbers (named after an Italian mathematician).Some Fibonacci numbers are 1, 1, 2, 3, 5, 8, ... where the next number is found by summing the preceding two numbers. Your program will read in a number, like 7, report the first 7 numbers. in this case1,1,2,3,5,8,13. Your program is not assured of receiving good data, thus if -2 is received as the number of numbers, then an error should be reported.Use C++ Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per line. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. Ex: If the input is: 0 or less, the output is: no change Ex: If the input is: 45 the output is: 1 quarter 2 dimes Your program must define and call the following function. Positions 0-4 of coinVals should contain the number of dollars, quarters, dimes, nickels, and pennies, respectively.void ExactChange(int userTotal, vector<int>& coinVals)2. Write a program that generates a number randomly by using rand ( ) function and user will have to guess that number. (Note: If the number is greater or smaller than user-entered number, your program should tell that the entered number is greater or smaller than computer-generated number and your program should terminate after correct number is guessed). sample program run is shown in the picture.