Skip to content

Smathuki/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

calculator

my first java calculator

// Importing the Scanner class from java.util package

// Main class that contains the entry point of the program // Creating a Scanner object for user input // Declaring variables to store the numbers entered by the user

// Prompting the user to enter the first number
// Reading and storing the first number entered by the user

// Prompting the user to enter the second number
// Reading and storing the second number entered by the user

// Displaying the menu of operations to the user

// Reading the choice of operation entered by the user

// Using a switch statement to perform the selected operation
    // Calling the add() method and displaying the result
    // Calling the subtract() method and displaying the result
    // Calling the multiply() method and displaying the result

    // Checking if the second number is zero to avoid division by zero
        // Displaying an error message if the second number is zero
    // Calling the divide() method and displaying the result

    // Handling an invalid choice entered by the user

// Closing the Scanner object to release resources

// Method to perform addition

// Method to perform subtraction

// Method to perform multiplication

// Method to perform division

About

my first java calculator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages