Skip to content

This project was for testing my programming skills in java, while studying a java object oriented programming course

Notifications You must be signed in to change notification settings

OrdoGeek/SimpleGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

SimpleGame

This project was for testing my programming skills in java, while studying a java object oriented programming course

INSTRUCTIONS

The task was the next one:

In this assignment, you will implement a simple game. This game has 2 options for the user playing. Based on user input, the user can choose to either convert time, from seconds to hours, minutes, and seconds, or calculate the sum of all digits in an integer.

At the beginning of the game, the user will be prompted to input either 1 or 2, to indicate which option of the game they want to play. 1 will indicate converting time, and 2 will indicate calculating the sum of digits in an integer.

For converting time, the user will be prompted to input a number of seconds (as an int) and the program will call a method that will convert the seconds to time, in the format hours:minutes:seconds, and print the result. For example, if the user enters 6734, the program will print the time, 1:52:14. As another example, if the user enters 10,000, the program should print 2:46:39.

For calculating the sum of digits in an integer, the user will be prompted to input a number (as a non-negative int) and the program will call a method to calculate the sum of the digits in that number, and print the result. For example, if the user enters 321, the program will print the sum, 6, because the individual digits in the number add up to 6. 3 + 2 + 1 = 6.

There are 2 methods that need to be implemented in the SimpleGame class:

  • convertTime(int seconds) - Method that converts a given number of seconds to time in the format hours:minutes:seconds.
  • digitsSum(int input) - Method that adds all the digits in a given non-negative integer.

CODE - SOLUTION

you can find the script right here on this repository

IMPLEMENTATION

  1. Screenshot from 2022-11-08 17-29-18
  2. Screenshot from 2022-11-08 17-29-41
  3. Screenshot from 2022-11-08 17-30-06
  4. Screenshot from 2022-11-08 17-30-22

About

This project was for testing my programming skills in java, while studying a java object oriented programming course

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages