The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Lab Assignment #5
Due date: 12:00, 10/3/2016
Problem Description
Write the math quiz and coin flipping programs from assignments 3 and 4, but this time using sub-methods instead of having the code within the main method.
Assignment Requirements
Write out two sub-methods, one representing the math quiz and the other the coin flipper.
The math quiz sub-method should adhere to the following requirements:
Boolean return type
One int parameter
The sub-method will use the supplied int parameter to determine which quiz to administer to the user (1 for addition, 2 for subtraction, 3 for multiplication, 4 for division). The program will then create a quiz with two randomized, single digit numbers with the operation requested by the user. If the user answers the question correctly, the program will return a Boolean of TRUE, otherwise it will return a Boolean of FALSE.
The coin flipper sub-method should adhere to the following requirements:
Void return type
Three int parameters
The sub-method will take the first int parameter to determine whether the user wants to favor heads or tails for the coin (1 being heads, 2 being tails). The method will then take the second int and use that as the amount to favor the given side (for instance, if the user indicates heads by 10, the chance to flip a heads will become 60%). The third int will be used to determine the number of times to flip the coin. The sub-method will then output the number of heads and the number of tails from the flip(s).
In the main method of your program, make the following calls to the two sub-methods:
Call the math quiz using the following parameter: (1)
Output the return
Call the math quiz using the following parameter: (3)
Output the return
Call the coin flipper using the following parameters: (1, 0, 1000)
Call the coin flipper using the following parameters: (1, 20, 1000)
Call the coin flipper using the following parameters: (2, 40, 1000)
Call the coin flipper using the following parameters: (2, 50, 1000)
The modifiers of your sub-methods should be public static so that they are visible and accessible from the main. You may name your sub-methods whatever you like.
Create screenshots for each sub-method call. Create a flowchart of the main method, you do not need to create nor include flowcharts of the submethods.
Submission Requirements
Your assignment submission should include the following items:
Flowchart of the main method
The Java source code file (i.e., *.java file)
The screen captures of the results of the six method calls
Submit all files into the dropbox of this assignment.
Assignment Assessment
The assessment rubric for the assignment is below:
|
Task Items |
Complete & Correct |
Incomplete/ |
Missing |
|
Solution Design |
100% |
By % |
0 |
|
Solution Pseudo-Code (Java comments) (10%) |
100% |
By % |
0 |
|
Java Program (60%) |
100% |
By % |
0 |
|
Testing Completeness (20%) |
100% |
By % |
0 |
Please do not email your assignment to the instructor.
CIS 3260 Introduction to ProgrammingLab Assignment #3Due date: 12:00 pm, 9/19/2016Problem DescriptionCreate the fowchart and program For an arithmetic quiz. The program will ±rst askthe user which oF Four operations they want to test (addition, subtraction,multiplication, or division). The program will then create a ‘quiz’ with the indicatedoperation andtwo randomized, single digit, non-negative integers (For instance, iFthe user indicates multiplication, the quiz will be “What is 3*8?”). IF the user entersa correct response to the question, the program congratulates the user. Otherwise,the program will say the answer is wrong and display the correct answer.Assignment Requirements²ollow the Following problem solving steps to aid in completing the assignment:1Draw a simplefowchart diagram showing the process fow oF the program. Youmay use any soFtware that is capable oF drawing fowchart diagrams like draw.io orMS PowerPoint.2I strongly recommend creating thepseudo-code For this assignment beForebeginning coding.1) You may use eitherScanner or JOptionPane to accept user input and display output.2) An easy way to determine operation From input is to map each to a number (Forinstance, addition = 1, subtraction = 2, and so on)3) You will need to provide screenshots oF 5 test runs (+, -, *, /, and incorrect answer)4) Do not Forget your programheaderRun and create screenshots oF the Following test casesOperationUser ResponseTest case 1+CorrectTest case 2-3CorrectTest case 3*3CorrectTest case 4/CorrectTest case 5AnyWrongExample Runs of the ProgramOutput: What operation (+ = 1, - =2, * = 3, / = 4)?Input: 2Output: What is 8-4?Input: 4Output: Correct! Good job! Yay!You did it!Output: What operation (+ = 1, - =2, * = 3, / = 4)?Input: 3Output: What is 3*9?Input: 15Output: Incorrect, the answer is27.1
Problem DescriptionWrite a coin fipping program with a twist, you can manipulate the coin toss to Favoreither heads or tails. The program will ask which side oF the coin the user wants toFavor, heads, tails, or neither. The program will then ask the user how much that sidewill be Favored. ±or instance, iF the user indicates that they want to Favor heads by 20,the probability oF the coin fipping heads will be 70%. Next, the program will ask howmany times the user would like to fip the manipulated coin and will simulate thatmany fips. ±inally, the program will tell the user how many times each side wasfipped.Assignment Requirements1) Create a fowchart detailing the program2) Create adequate pseudocode For each portion oF the code, do not Forget yourprogram header3) The program needs to accept user input to determine three things, the side to Favor,the percentage, and the number oF times the coin will be fipped4) You will need to run Four test cases detailed below and provide screenshotsshowing you have run the cases:CaseSide to favorPercentage tofavorNumberof Fips1NeitherN/A10002Heads20%10003Tails10%10004Tails50%1000Example run of the programSubmission RequirementsYour assignment submission should be prepared as Follows:1
Attachments:
-----------