Write a
For each coin toss enter either h for heads or t for tails.
First toss : h
Second toss : t
Third toss : t
Fourth toss : h
Fifth toss : t
Sixth toss : h
Seventh toss : t
Eighth toss : t
Number of heads : 3
Number of tails : 5
Percent heads : 37.5
Percent tails : 62.5
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Modern Database Management (12th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out With Visual Basic (7th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
- Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked during the month, validate that it is between 1 and 31, and then display a table showing how much the salary was for each day worked, as well as the total pay earned for the month. The output should be displayed in dollars with two decimal points, not in pennies.arrow_forwardMeadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a program that prompts a user for the number of eggs in the order and then display the amount owed with a full explanation using the following wording: You ordered 27 eggs. That’s 2 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $7.85. So far everything is right but something in my equations is causing my ouput to show up as 45.0arrow_forwardMeadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a program that prompts a user for the number of eggs in the order and then display the amount owed with a full explanation using the following wording: You ordered 27 eggs. That’s 2 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $7.85. write a program that calculates the following: The program calculates the cost of 12 egss The program calculates the cost of 35 eggs The program calculates the cost of 6 eggs JAVA import java.util.Scanner; class Eggs { public static void main(String[] args) { // Write your code here } }arrow_forward
- In this exercise you will write a program for printing out grade statistics for a university course. The program asks the user for results from different students on the course. These include exam points and numbers of exercises completed. The program then prints out statistics based on the results. Exam points are integers between 0 and 20. The number of exercises completed is an integer between 0 and 100. The program kees asking for input until the user types in an empty line. You may assume all lines contain valid input, which means that there are two integers on each line, or the line is empty. And example of how the data is typed in: Exam points and exercises completed: 15 87 Exam points and exercises completed: 10 55 Exam points and exercises completed: 11 40 Exam points and exercises completed: 4 17 Exam points and exercises completed: Statistics: Sample outputarrow_forwardAssignment 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…arrow_forwardArchery Scorer. Write a program that draws an archery target (see Pro-gramming Exercise 2 from Chapter 4) and allows the user to click five times to represent arrows shot at the target. Using five-band scoring, abulls-eye (yellow) is worth 9 points and each successive ring is worth 2fewer points down to 1 for white. The program should output a score foreach click and keep track of a running sum for the entire series.arrow_forward
- Write a program that helps a company manage salaries of its employees. Your program should ask for the number of hours worked and the hourly rate of an employee than, display the salary. This program still asks the user to enter the information of many employees until enters a zero value. Sample Run: Enter the number of hours worked (negative nbr to end): 32 Enter hourly rate of the worker: 100 Your salary is $3200 Enter the number of hours worked (negative nbr to end): 40 Enter hourly rate of the worker: 5 Your salary is $200 Enter the number of hours worked (negative nbr to end): 42 Enter hourly rate of the worker: 10 Your salary is 5420 Enter the number of hours worked (negative nbr to end): 0arrow_forwardIn CORAL LANGUAGE please and thank you! Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part. Ex: If the input is: 130 50 130 the output is: 80 0 80 Hint: Find the smallest value, and then subtract it from all three values, thus removing the gray.arrow_forwardA robot sits in a 30 foot square room. It be directed to travel a randomly generated distance between 8 and 20 feet. The user will input a value that will serve as the seed for the random number generator. Every foot it travels it indicates that it has traveled 'x feet'. Upon arrival at the user specified distance, it announces." made it!"(This will happen even if the robot moves 0 feet). The program should also indicate how many more feet the robot could travel before running into a wall assuming it always starts at one wall of the room. Note that grammar used to indicate singular versus plural distances. i.e. for an random generation of 5, the resulting output should be: How far should the robot travel? 5 feet 1 foot I made it! I can only travel 25 mor 2 feet 3 feet 4 feet 5 feet e feet. tabs are used to space the output of traveled feet 330492.1753326.qx3zay7 LAB АCTIVITY main.cpp 1 #include 2 using namespace std; 3 4 int main() int roomsize - 30; 6 int distance = 0; 7 8 cout <«…arrow_forward
- A small company needs an interactive program to compute an employee’s paycheck. The payroll clerk will initially input the data, and given the input data, an employee's wage for the week should be displayed on the screen for the payroll check. The data for the employee includes the employee's hourly pay rate and the number of hours worked that week. Wage is equal to the employee's pay rate times the number of hours worked (up to 40 hours). If the employee worked more than 40 hours, wage is equal to the employee's pay rate times 40 hours plus 1½ times the employee's pay rate times the number of hours worked above 40. Instruction: Rank the given pseudocodes according to their order of action: If employee’s number of hours worked is less than 0, go to 5 Set employee’s hourly pay rate to 0 Set employee’s number of hours worked to 0 Print “Employee’s wage is ”, employee’s wage Else, employee’s wage = employee’s hourly pay rate x hours Else, go to 5 Else, go to 8 Get employee’s hourly pay…arrow_forwardWrite a program that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic averagearrow_forwardProblem: An online grocery store sells items on a web page. A user adds items to a basket and he clicks on the submit button when he completes. The store sells food and electronic items. The electronic items require VAT payment of 15 percentage of their prices. There are packed and lose food. The lose food is measured in weights. User specifies the weight amount or the quantity in his selection of items depending on its type. The price is computed as the product of the price per item or the price per weight and the weight or quantity are given by the user. Write an application that reads a user basket list and produces the bill receipt. Check the given samples of input/output in the figures below. The bill receipt contains the list of item details in decreasing order according to the price computed for each item. Use the selection sort' to sort the items in the list and do not use java given sort method. Selection sort is an algorithm used to arrange elements in a list. It selects the…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage