
2. Write a java program which will input an integer value from the user (Use Scanner class).
Your program will have mathOper() method in addition to the main() method.
The main() method will be responsible for:
a. extracting the 1's digit (ones), the 10's digit (tens), and any digits larger than the 10's digit.
For instance, if the input is 3562, the 1's digit would be 2, the 10's digit would be 6, and
the remaining digits would be 35.
b. call the mathOper() method with these 3 values,
c. print the results to the screen.
The mathOper() method will make the following calculations:
a. Multiply the 1's digit by 7, subtract the result by 2 and then divide that by 5.
b. Add 3.5 to the 10's digit, multiply the result by 4.3 and then divide that by 2.
c. Subtract 5 from the remaining digits, multiply the result by 3, find the remainder after
dividing that by 7, and then add 6 to the remainder value.
d. Add the 3 values obtained from ‘a’, ‘b’, and ‘c’ operations.
e. Return the final value.
Sample output (assuming the input is 419):
The mathOper value of 419 is 24.875

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- Write a Java program to test if a given string contains only digits and special symbols (+,=*/,%,&,$) User inputs a string and program prints out true if the input string contains only digits and special symbols ; otherwise it prints out false. You may use Scan objects and loops. Example 1: Input a string to check: 123/5=$ Result: true Example 2: Input a string to check: 123bad Result: falsearrow_forwardComputer Science Write a Java program that reads a line and a line segment and then determines whether they intersect or not. When they overlap completely, consider that as intersecting. Use variables ((lp1x, lp1y), (lp2x, lp2y)) to represent a line and ((sp1x, sp1y), (sp2x, sp2y)) to represent a line segmentarrow_forwardWrite a Java Program to take 3 integers(a.b.c) from the user, print "Great Number" if one of b or c is "close" to a (differing from a by at most 1), while the other is "far", differing from both other values by 2 or more. else print "Ugly Number".arrow_forward
- I needed some help with this java homework assignement. We use eclipse. CIS365 Hw1: Count LetterWrite a Java program (CountLetter.java). Input a sentence from keyboard. Print out how many letters "a", "e", "o" and the percentage of each letter in the whole sentence. Please enter a sentence, ended by period '.': (5 points)Sentence.... (10 points)There are 20 letters (10 points)a: 1, 5% (20 points)e: 0, 0% (20 points)o: 4, 20% (20 points)arrow_forwardMake a Simple unit converter in Python that supports (length and time) and inputs the value and the initial unit measurement. Using the mentioned measurements (length and time). The user will pick either length or time. it then computes and shows the three types of conversion (Ex. 12 inches = (1) foot/feet, (30.48) centimeters, (304.8) millimeters). The unit conversion program allows the user to input a chosen conversion and repeats the program until the word “stop” is typed.arrow_forwardUsing Java, generate an integer value within range "[0, 2000000000]" (9 zeros after digit 2) in the program. You can just implement this by writing an integer literal in your source code. Then the player needs to guess this number via a series of keyboard inputs. You are required to display the candidate range that the answer lies in on this screen to help the player make the guess. If the player's guess exactly match the answer, you should tell the player that he/her made a correct guess. Otherwise, you need to tell the player whether the proposed guess is larger or less than the answer. In the meantime, you should print out a candidate interval to narrow down the range that the answer lies in. This candidate interval should incorporate all the information based on all previous guesses from the player. Finally, when the player makes a correct guess, you should also print out how many times that the player spent to reach the correct answer. You should count the last time in this value.…arrow_forward
- I am struggling with this problem. This is the question - Write an application that asks a user to enter an integer. Display a statement that indicates whether the integer is even or odd. This is the code I have done so far but it is not working and I am unsure how to fix what I am doing. import java.util.Scanner; class EvenOdd { public static void main(String[] args) { //scanner for user input Scanner input = new Scanner(System.in); //declaring the number of user int number; //scanner and user input System.out.println("Please enter the integer: "); number = input.nextInt(); //output for the even and odd System.out.println("The integer entered is even."); System.out.println("The integer entered is odd."); } public static boolean isEven(int number) { //the if statement for above if (number % 2 == 0) { number = even; } else {…arrow_forwardWrite a Java program that will 1. Ask the user to type in a sentence, using a JOptionPane.showInputDialog(). 2. The program will examine each letter in the string and count how many time the upper-case letter 'E' appears, and how many times the lower-case letter 'e' appears. The key here is to use the charAt method in class String. 3. Using a JOptionPane.showMessageDialog(), tell the user how many upper and lower case e's were in the string. 4. Repeat this process until the user types the word "Stop". (Check out the method equalsIgnoreCase in class String to cover all upper/lower case possibilities of the word "STOP"arrow_forwardWrite a Java program which reads a 3-digit number from command-line and prints whether that number is an Armstrong number or not.A 3-digit Armstrong number is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 33 + 73 + 13 = 371, but 173 is not an Armstrong number.Sample output (assuming the command line argument is 371):The number is an Armstrong numberarrow_forward
- 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





