Concept explainers
If originally
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
- To calculate VAT on a price without VAT, you can use the formula:VAT = VAT Rate ∗ price Without VAT Make a program that first reads in a price without VAT and that calculates the VAT and the price with VAT.The program will then print out the VAT and the price with VAT.The VAT rate must be 25%.(Note: VAT rate! = VAT, see the formula.)Write the program so that you only need to change one place in your code if you want to change the VAT rate. The VAT rate should not be hard-coded directly in the calculations.Example of user dialog: (Bold indicates input from the user.)Enter price in SEK, without VAT: 1000VAT: SEK 250Price with VAT: 1250 krTesting:Try entering different values. Check that the program is counting correctly.arrow_forwardWrite a code snippet that prompts the user for an integer named number and prints out “Good Number” if the input meets any one the following conditions, and prints out “Bad Number” if it does not : number equals 5 number equals 7 number is between 10 and 20 (non-inclusive) number is greater than 30.arrow_forward3. B) What is the value of num when the following code snippet runs successfully? int num = 100; if (num < 100) { if (num < 50) { num -= 5; } else { num -= 10; } } else { if (num > 150) { num += 5; } else { num += 10; } } C) A store provides 10 percent discount on all items with a price of at least $100. No discount is otherwise applicable. Assume that two variables are declared, discount and price. Write the code segment that does the job.arrow_forward
- Question 5 What is the output of the following code segment? int num cin>>x; = 20, 5, X; if (x >= 2*num) y+=1; else if (x >= num) y+=2; if (xarrow_forwardint main(){ if(var1>50) { num = 20.0 } else { if(var1>35) ---- Line 7 { num= 35.0; } else if (var1<80) { num=60.0; } else { num=40.0; }} What should be the outcome of the condition in line 7 in order for the value of num to be equal to 60.0?arrow_forwardCode C was used to make this Can this be done in a form of a flowchart please? 1. Prompt the user and read in the number of a team playing the current game, i.e. Team 1,Team 2, Team 3, etc.2. Prompt the user and read in the number of the opponent team. It is probably helpful to think of the first team as the home team for this game, and the second team as the away team. 3. Prompt the user and read in a team’s score for the current game. Use the team’s number when asking for the score in your printf statement.4. Prompt the user and read in the opponent’s score for that game. Again, use the opponent’s team number when asking for the score.5. Notify the user and repeat steps 3 and 4 in the case that the user enters a negative value.6. Calculate the points earned by each team and add it to a cumulative score. A win is worth 3 points, a draw is worth 1 point and a loss is zero points. Also update the amount of games played by each team and their goals for and against. 7. Print to the…arrow_forward
- Malcolm Movers charges a base rate of $200 per move plus $150 per hour and $2 per mile. Write a program named MoveEstimator that prompts a user for and accepts estimates for the number of hours for a job and the number of miles involved in the move and displays the total moving fee. For example, if 25 hours and 55 miles are input the output would be displayed as: For a move taking 25 hours and going 55 miles the estimate is $4,060.00 In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));arrow_forwardGiven the code below: type point real a, b end type type (point) v read*, v z=v%a/v%b print*, z end What is the equivalent code for the above statements? Question 6 options: none of the given code choices type point real a, b end type type (point), dimension(2):: v read*, v do i=1, 2 z=v(i)%a/v(i)%b end do print*, z end all the given code choices type point real a, b end type type (point), dimension(2):: v read*, v where (i>0) z=v(i)%a/v(i)%b end where print*, z end real va, vb read*, va, vb z=va/vb print*, z endarrow_forwardThe cost of renting a room at a hotel is, say $100.00 per night. For special occasions, such as a wedding or conference, the hotel offers a special discount as follows: If the number of rooms booked at least 10, the discount is 10%; at least 20, the discount is 20%; and at least 30, the discount is 30%. Also if rooms are booked for at least three days, then there is an additional 5% discount. Write a program that prompts the user to enter the cost of renting one room, the number of rooms booked, the number of days the rooms are booked, and the sales tax (as a percent). The program outputs the cost of renting one room, the discount on each room as a percent, the number of rooms booked, the number of days the rooms are booked, the total cost of the rooms, the sales tax, and the total billing amount. Your program must use appropriate named constants to store special values such as various discounts.arrow_forward
- Suppose the Great Frederick Fair wants to update its ticketing software. They need you to write a program tohandle the price calculations, using the rules*:• The basic price of a ticket is $40.• Senior citizens (age >= 65) get a 50% discount.• Children under 6 are free (100% discount).• For residents of Frederick County, the basic price is $35; the same discounts still apply.So the individual ticket prices range from $0 to $40.Your program should request age and county name from the user. The age will be entered as an integer and thecounty name as a string.Before calculating the price, confirm that the user's age is valid – not negative and not more than 110. If it is not,give a message and do not do the price calculation. Also, the county name should not be case sensitive – forexample, Frederick, frederick, and FREDERICK should all be acceptable.Your program should then calculate and print out the ticket price, using the appropriate discounts.Test your program with a variety of…arrow_forwardSuppose the Great Frederick Fair wants to update its ticketing software. They need you to write a program tohandle the price calculations, using the rules*:• The basic price of a ticket is $40.• Senior citizens (age >= 65) get a 50% discount.• Children under 6 are free (100% discount).• For residents of Frederick County, the basic price is $35; the same discounts still apply.So the individual ticket prices range from $0 to $40.Your program should request age and county name from the user. The age will be entered as an integer and thecounty name as a string.Before calculating the price, confirm that the user's age is valid – not negative and not more than 110. If it is not,give a message and do not do the price calculation. Also, the county name should not be case sensitive – forexample, Frederick, frederick, and FREDERICK should all be acceptable.Your program should then calculate and print out the ticket price, using the appropriate discounts.Test your program with a variety of…arrow_forwardWrite a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:BMI = weight × 703 / height2where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweight please write code on c++arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage