CS 1102-Unit01 programming assignment
.docx
keyboard_arrow_up
School
University of the People *
*We aren’t endorsed by this school
Course
1102
Subject
Computer Science
Date
Jan 9, 2024
Type
docx
Pages
3
Uploaded by BaronEmuPerson965
You are tasked with creating a Java program that simulates a simple quiz game. The program should prompt the user with a series of questions and allow them to enter their answers. After the user has answered all the questions, the program should compute and display the final score based on the number of correct answers.
For this assignment, write a Java program that implements the functionality described in the scenario. Ensure that your program is error-free, compiles successfully, and produces the expected output. Test your program with different inputs to verify its correctness.
Make sure the following requirements are met:
o
The program should include five multiple-choice questions with four options.
o
The four options should be labeled A, B, C, and D.
o
The program should prompt the user to enter their answer by typing the corresponding letter (A, B, C, or D).
o
After the user has entered their answer for each question, the program should compare it to the correct answer and keep track of the number of correct responses.
o
The program should compute and display the final score as a percentage of the total number of questions.
o
Use if and switch case statements to handle user input and compare it to the correct answers.
o
Include comments to explain the purpose of each section of code and enhance code readability.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Make a Java program.
Do not copy codes from other sites.
arrow_forward
please do both Questions.
arrow_forward
Please answer this question in Java language
with a screenshot of the output and .java file
arrow_forward
Write a Java program (TicTacToe.java) for playing tic-tac-toe. You may assume that two human players are playing against each other. Your program should display an updated board before every turn, prompt the user to enter the row and column in which to play, and display "X wins!", "O wins!", or "Tie!" at the end of the game.
Here is a sample run of a correct program (user input indicated by orange text):Let's play Tic-Tac-Toe!
- - -- - -- - -Enter a row and column (1, 2, 3) for player X: 2 2
- - -- X -- - -Enter a row and column (1, 2, 3) for player O: 2 3
- - -- X O- - -Enter a row and column (1, 2, 3) for player X: 1 1
X - -- X O- - -Enter a row and column (1, 2, 3) for player O: 1 3
X - O- X O- - -Enter a row and column (1, 2, 3) for player X: 3 3
X - O- X O- - XX wins!
arrow_forward
Coronavirus (COVID-19) is causing a lot of panic the world over. Most people in developing countries are panicking because there are not proper test kids to determine whether one has the virus or not. You have been consulted to develop a program that could be used as a first step in determining the likelihood that one has it or not so that persons could then be referred to the testing center to be tested. Your task is to:a. Write a java program that request for1. A person’s age2. Temperature3. Dry cough4. Sneezing5. Running nose b. Your program should refer to the testing center when:1. Temperature >38oC and Sneezing, Running nose, Dry cough allrespond to yes
2. Or Temperature >38oC and any two from “a 3 – 5” above all respondto yes 3. Otherwise your program shouldn’t display go home
arrow_forward
Solve in JavaBuying/Selling Shares of Stocks Buying and selling shares of stocks of listed companies is a typical task to do among investors. Of course, this would result in a capital gain (or loss) when the shares are sold. This is computed as the difference between the shares' selling price and the price was originally paid to buy it. When an investor has a single share of stock, the process is easy. However, when (s)he sells multiple shares of stocks, bought over a period of time and possibly with different prices, the first step is to identify which shares of stocks are to be sold. There are two accounting principles (protocols) that are followed depends on the market of stocks: the shares bought last to be sold first, and the other is to sell the shares that stayed the longest. You are required to implement a program to calculate the possible capital gain/loss using these two protocols. This would facilitate the process for investors to know which market to go for and invest their…
arrow_forward
Write a code in Java programming:
You are asked to create a smart home system for collecting two sensor data from a thermometer and a hygrometer. Both sensor data should continuously show on a monitor.
The data collecting frequency for the thermometer is about 1 second, and the frequency for the hygrometer is about 2 seconds. In addition, the data range for a thermometer is between 0 to 45 degrees, and the data range for a hygrometer is between 0 to 100%.
Both sensors should run forever unless the user shuts down the system.
You should implement this system according to the design below:
Please check below for a sample output when the system is activated. You must follow the system design and have the same printing format in order to receive full marks.
[Thermometer]:5 degree
[Hygrometer]:84%
[Thermometer]:9 degree
[Thermometer]:21 degree
[Hygrometer]:57%
[Thermometer]:15 degree
[Thermometer]:14 degree
[Hygrometer]:96%
[Thermometer]:29 degree
[Thermometer]:6 degree
[Hygrometer]:22%…
arrow_forward
Exercise 1:
Create a JAVA program that prompts the user to enter a numerical test mark and displays the
corresponding feedback of the "test mark", using the following equivalence:
9, 10 = Outstanding
7,8 = Notable
6 = Good
5 = Approved
0 - 4 = Fail
Your program must ask the user for a numerical mark and display the corresponding test mark. Your
code should at first validate the user input to be a positive integer value.
You must solve this problem using both:
"if" condition.
"switch" condition.
arrow_forward
Write a Java program that lets the user enter a series of integers with an input range from 2 to 199. The user must enter a value of -1, 0, +1, or +3 (a sentinel which must be an integer and not part of the series of numbers) in order to signal the end of the series.
After all the numbers have been entered, the program should display the smallest and largest numbers entered, and not include the sentinel. Note that this must be a Java implementation, and not pseudo-code, etc. You must use a Loop and If-Else/Select constructs as well.
Also include a flow-chart.
arrow_forward
Write a java program to simulate a car insurance
We have a problem, which is calculating the insurance price at a unified price for all categories.to solve this problem I want to calculate the insurance price in addition to the factors in the uml. For example, if the individual's age is from 18-25, the insurance rate will increase by 1% over the basic price, as well as the type of car and the gender of the person who wants insurance, for example, if a man also increases 1 % and so are all the factors. If you cannot write the entire program, it is not a problem. Write at least the equations for calculating the insurance or half of the program also You can put random numbers and random prices.
arrow_forward
Write a java program to simulate a car insurance
We have a problem, which is calculating the insurance price at a unified price for all categories.to solve this problem I want to calculate the insurance price in addition to the factors in the uml. For example, if the individual's age is from 18-25, the insurance rate will increase by 1% over the basic price, as well as the type of car and the gender of the person who wants insurance, for example, if a man also increases 1 % and so are all the factors. If you cannot write the entire program, it is not a problem. Write at least the equations for calculating the insurance or half of the program also You can put random numbers and random prices.
arrow_forward
Write a java program to simulate a car insurance
We have a problem, which is calculating the insurance price at a unified price for all categories.to solve this problem I want to calculate the insurance price in addition to the factors in the uml. For example, if the individual's age is from 18-25, the insurance rate will increase by 1% over the basic price, as well as the type of car and the gender of the person who wants insurance, for example, if a man also increases 1 % and so are all the factors. If you cannot write the entire program, it is not a problem. Write at least the equations for calculating the insurance or half of the program also You can put random numbers and random prices.
arrow_forward
Write a Java application to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12 the least frequent.Your application should roll the dice 12 times. Use a one-dimensional array to tally the number of times each possible sum appears. Display the results in tabular format. */
arrow_forward
In Java.
arrow_forward
write a java program
arrow_forward
Writing a Modular Program in Java
Summary
In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be able to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.
Instructions
Notice that variables have been declared for you.
Write the simulated housekeeping() method that contains input statements to retrieve a year, a month, and a day from the user.
Add statements to the simulated housekeeping()method that convert the String representation of the year, month, and day to ints.
Include the output statements in the simulated endOfJob()method. The format of the output is as follows:month/day/year is a valid date. or month/day/year is an invalid date.
Execute the program entering the following date: month = 5, day = 32, year =2014Observe the output of this…
arrow_forward
In Java:
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:
tails heads tails
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 create an instance of Random before each call to rand.nextInt(). But seeding should only be done once, at the start of the program, after which rand.nextInt() can be called any number of times.
Your program must define and call the following method that returns "heads" or "tails".public static String headsOrTails(Random rand)
import java.util.Scanner;import java.util.Random;
public class LabProgram {/* Define your method here */public static void…
arrow_forward
Write a Java program to simulate a blackjack game of cards. The computer will play the role of the dealer. The program will randomly generate the cards dealt to the player and dealer during the game. Cards in this game will be represented by numbers 1 to 13 with Ace being represented by a 1. Remember, that face cards (i.e. Jack, Queen, and King) are worth 10 points to a hand while an Ace can be worth 1 or 11 points depending on the user’s choice. The numbered cards are worth their number value to the hand. Here are the details of how to play the game: To start the game, the player is given two randomly chosen cards and told their values. The dealer is then given two cards randomly. The human player should only be told the value of the first card given to the dealer. The other card in the dealer's hand is "hidden" until the end of the game. The player is then asked if they want to draw another card for their hand. While the player wishes to draw another card and neither hand has gone…
arrow_forward
Write a FULL Java procedural program for a simple word guessing game. Below is an example of the required program behaviour. The bold text is user keyboard input. The player is allowed to guess one letter or the whole word incorrectly up to 5 times; each incorrect guess is called a “strike”.
The program starts by displaying one full stop (’.’) for each character of the secret word. You may assume the word is hardcoded into the game, is in lower case, and is of length greater than one.
In each round of the game, the game first checks if the player has reached the maxinum number of strikes; if so, the player loses and the game ends. If not, the game prints an input prompt.
The player then guesses either one letter (by entering a single character) or the whole word (by entering multiple characters). If a single letter is guessed correctly, meaning the character occurs in the word, the game reveals the positions of those occurrences in the word and proceeds to the next round.
If the whole…
arrow_forward
Write a Java program to simulate a blackjack game of cards. The computer will play the role of the dealer. The program will randomly generate the cards dealt to the player and dealer during the game. Cards in this game will be represented by numbers 1 to 13 with Ace being represented by a 1. Remember, that face cards (i.e. Jack, Queen, and King) are worth 10 points to a hand while an Ace can be worth 1 or 11 points depending on the user’s choice. The numbered cards are worth their number value to the hand. Here are the details of how to play the game: To start the game, the player is given two randomly chosen cards and told their values. The dealer is then given two cards randomly. The human player should only be told the value of the first card given to the dealer. The other card in the dealer's hand is "hidden" until the end of the game. The player is then asked if they want to draw another card for their hand. While the player wishes to draw another card and neither hand has gone…
arrow_forward
Write a Java program code:
Scenario:One of the renowned supermarket in Dhaka City, “Shwapno” is celebrating their firstanniversary of opening. They have become very popular among people in a short amount oftime. As a method of celebration they have designed three interesting and exciting offer for theircustomers for that day only!! The offers are described as follows:Offer 1: This offer says, if the name of any customer starts with “S” OR ends with “o”, theywill receive a gift which contains 1 kg miniket rice and 1 litre soyabean oil. This offer isdedicated from their name, Shwapno.Offer 2: This offer says, if one customer have taken products and his/her total product weightis less than 1.50 kg, then Shwapno will give all the products to the customer for free. If the totalweight is 1.50 kg or more, the customer will have to pay the full amount.Offer 3: This offer says, if a customer is aged less than 15, then he/she will receive chocolates.If aged 15 or more, then no gifts for the…
arrow_forward
please do it in java programming
arrow_forward
Make a java program that lets student enter their grades for subject a,subject b, subject c, subject d, subject e, subject f, subject g, subject h. Total of 8 subjects.
Use this website:
[https://www.jdoodle.com/online-java-compiler/] to
do this
Please give me the program code and output. Clear
picture please. Preferably vertical so i can just
rotate it to read it. Thank you
arrow_forward
Please I need a simple solution in Java language
arrow_forward
Write a well-documented, efficient Java program that implements the algorithm you identified. Include appropriate documentation as identified in the documentation expectations document.
Note: You must use the JOptionPane class for input/output. Additionally, if you use System.exit as shown in the textbook, it may only be used as the absolute last line in the program. You may not use System.exit, or any variant that exits the program in the middle of the program. The program should be designed to only exit once the algorithm has finished.
Imagine you have just purchased your first home. As your first house project, you have decided on adding a fence in your backyard. You have contacted several local contractors and receive their project bids (estimated cost) and rating (out of 5 stars). These bids will be provided by up to five different contractors. In order to perform the evaluation, your application should select the winning bid with the highest rating and the lowest cost within…
arrow_forward
Use JAVA to create a card game in which the dealer shuffles the deck and deals 13 cards out of the 52 to the player. The player sorts her hand and says whether it includes the King of Hearts. Repeat 4 times so all the cards are dealt eventually. Internally, the player should return true or false without writing to the console. In response, the dealer should write on the console, "You won!" or "You loose again." Also create a unit test for the win and loose cases.
arrow_forward
Please help with this Java Lab
arrow_forward
In Java inputs and output values can easily be manipulated, for example when dealing with money the value should always be formatted to 2 decimals or another use is separating of words in even spaces, line breaks and etc. Your task is to prompt the user for 2 numbers one integer the other decimal and print their product in money format. The program should also take in two words delimitated by @ symbol.
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Write a Java program (TicTacToe.java) for playing tic-tac-toe. You may assume that two human players are playing against each other. Your program should display an updated board before every turn, prompt the user to enter the row and column in which to play, and display "X wins!", "O wins!", or "Tie!" at the end of the game. Here is a sample run of a correct program (user input indicated by orange text):Let's play Tic-Tac-Toe! - - -- - -- - -Enter a row and column (1, 2, 3) for player X: 2 2 - - -- X -- - -Enter a row and column (1, 2, 3) for player O: 2 3 - - -- X O- - -Enter a row and column (1, 2, 3) for player X: 1 1 X - -- X O- - -Enter a row and column (1, 2, 3) for player O: 1 3 X - O- X O- - -Enter a row and column (1, 2, 3) for player X: 3 3 X - O- X O- - XX wins!arrow_forwardCoronavirus (COVID-19) is causing a lot of panic the world over. Most people in developing countries are panicking because there are not proper test kids to determine whether one has the virus or not. You have been consulted to develop a program that could be used as a first step in determining the likelihood that one has it or not so that persons could then be referred to the testing center to be tested. Your task is to:a. Write a java program that request for1. A person’s age2. Temperature3. Dry cough4. Sneezing5. Running nose b. Your program should refer to the testing center when:1. Temperature >38oC and Sneezing, Running nose, Dry cough allrespond to yes 2. Or Temperature >38oC and any two from “a 3 – 5” above all respondto yes 3. Otherwise your program shouldn’t display go homearrow_forwardSolve in JavaBuying/Selling Shares of Stocks Buying and selling shares of stocks of listed companies is a typical task to do among investors. Of course, this would result in a capital gain (or loss) when the shares are sold. This is computed as the difference between the shares' selling price and the price was originally paid to buy it. When an investor has a single share of stock, the process is easy. However, when (s)he sells multiple shares of stocks, bought over a period of time and possibly with different prices, the first step is to identify which shares of stocks are to be sold. There are two accounting principles (protocols) that are followed depends on the market of stocks: the shares bought last to be sold first, and the other is to sell the shares that stayed the longest. You are required to implement a program to calculate the possible capital gain/loss using these two protocols. This would facilitate the process for investors to know which market to go for and invest their…arrow_forward
- Write a code in Java programming: You are asked to create a smart home system for collecting two sensor data from a thermometer and a hygrometer. Both sensor data should continuously show on a monitor. The data collecting frequency for the thermometer is about 1 second, and the frequency for the hygrometer is about 2 seconds. In addition, the data range for a thermometer is between 0 to 45 degrees, and the data range for a hygrometer is between 0 to 100%. Both sensors should run forever unless the user shuts down the system. You should implement this system according to the design below: Please check below for a sample output when the system is activated. You must follow the system design and have the same printing format in order to receive full marks. [Thermometer]:5 degree [Hygrometer]:84% [Thermometer]:9 degree [Thermometer]:21 degree [Hygrometer]:57% [Thermometer]:15 degree [Thermometer]:14 degree [Hygrometer]:96% [Thermometer]:29 degree [Thermometer]:6 degree [Hygrometer]:22%…arrow_forwardExercise 1: Create a JAVA program that prompts the user to enter a numerical test mark and displays the corresponding feedback of the "test mark", using the following equivalence: 9, 10 = Outstanding 7,8 = Notable 6 = Good 5 = Approved 0 - 4 = Fail Your program must ask the user for a numerical mark and display the corresponding test mark. Your code should at first validate the user input to be a positive integer value. You must solve this problem using both: "if" condition. "switch" condition.arrow_forwardWrite a Java program that lets the user enter a series of integers with an input range from 2 to 199. The user must enter a value of -1, 0, +1, or +3 (a sentinel which must be an integer and not part of the series of numbers) in order to signal the end of the series. After all the numbers have been entered, the program should display the smallest and largest numbers entered, and not include the sentinel. Note that this must be a Java implementation, and not pseudo-code, etc. You must use a Loop and If-Else/Select constructs as well. Also include a flow-chart.arrow_forward
- Write a java program to simulate a car insurance We have a problem, which is calculating the insurance price at a unified price for all categories.to solve this problem I want to calculate the insurance price in addition to the factors in the uml. For example, if the individual's age is from 18-25, the insurance rate will increase by 1% over the basic price, as well as the type of car and the gender of the person who wants insurance, for example, if a man also increases 1 % and so are all the factors. If you cannot write the entire program, it is not a problem. Write at least the equations for calculating the insurance or half of the program also You can put random numbers and random prices.arrow_forwardWrite a java program to simulate a car insurance We have a problem, which is calculating the insurance price at a unified price for all categories.to solve this problem I want to calculate the insurance price in addition to the factors in the uml. For example, if the individual's age is from 18-25, the insurance rate will increase by 1% over the basic price, as well as the type of car and the gender of the person who wants insurance, for example, if a man also increases 1 % and so are all the factors. If you cannot write the entire program, it is not a problem. Write at least the equations for calculating the insurance or half of the program also You can put random numbers and random prices.arrow_forwardWrite a java program to simulate a car insurance We have a problem, which is calculating the insurance price at a unified price for all categories.to solve this problem I want to calculate the insurance price in addition to the factors in the uml. For example, if the individual's age is from 18-25, the insurance rate will increase by 1% over the basic price, as well as the type of car and the gender of the person who wants insurance, for example, if a man also increases 1 % and so are all the factors. If you cannot write the entire program, it is not a problem. Write at least the equations for calculating the insurance or half of the program also You can put random numbers and random prices.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education