HW4

docx

School

Georgia Southern University *

*We aren’t endorsed by this school

Course

1301

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

2

Uploaded by BaronBoulderSeahorse44

Report
CSCI 1301 Homework #4 Due date: September 24, 2023 (Sunday), 11:59pm Your sister asks you to help her with learning factorials, and you decide to write a Java program that tests her skills. The program will let her input any positive integer. It will then generate a question asking what the factorial of that number is, as well as calculate the correct answer using a loop. She will then be prompted to enter the correct answer. The program should check her answer and should not let her continue until the correct answer is given. After she answers correctly, your program should ask whether she would like to try another starting number. If yes, your program should generate another corresponding factorial question. This procedure should repeat until she indicates no. As a reminder, a factorial is simply the product of all positive integers equal to or less than the number. Factorials are denoted by using ! . For example: 5! = 5 x 4 x 3 x 2 x 1 = 120 3! = 3 x 2 x 1 = 6 8! = 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 40,320 Factorials do not have special syntax in Java, so you must calculate a factorial by using a loop. Grading: This assignment is worth 100 points. If your program has compilation or run time errors, you will receive 0 points. Grade criteria Maximum points Correct result and output Proper implementation of all features specified in the program 80 Proper style and documentation * 20 The requirement of proper style and documentation can be found in “Expanded Guidelines on Programming Style and Documentation” document in the “Course Info” module in folio. How to hand in the assignment When you have finished your assignment, you will upload (submit) the java file to the Gradescope. If you do not submit the assignment before the due date, you will not be able to submit it. 1. Complete the assignment in a .java file. 2. Return to the folio > Gradescope> All Gradescope Assignments > HW4 to submit this assignment. Page 1 of 2
3. Browse for the assignment that you have on your computer, and select it so that it uploads to the assignment area. 4. Click “Upload”. For this assignment, please name your class file as “HW4” package homework; public class HW4 { public static void main(String[] args ) { //Please write your code here } } Your code should look exactly like the examples below and should be able to work for any positive integers: Note : Your output should look exactly like this: Page 2 of 2 Would you like to practice your factorials? (Answer 'true' or 'false'): true Please enter a number to begin practicing: 3 What does 3! equal? 8 Try again! What does 3! equal? 6 Correct! Would you like to practice your factorials? (Answer 'true' or 'false'): true Please enter a number to begin practicing: 5 What does 5! equal? 120 Correct! Would you like to practice your factorials? (Answer 'true' or 'false'): Would you like to practice your factorials? (Answer 'true' or 'false'): false Goodbye.
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