Reverses a three digit number producing a result

Assignment Help JAVA Programming
Reference no: EM13881626

Write a program called Rev.java to solve the following problem.

The program will optionally take a single three digit integer from the command line, e.g. as follows.

$ java Rev 351

If no number is supplied on the command line, then one will be prompted for as follows.

$ java Rev

Enter a three digit number, with the first digit larger than the third.

351

Either way, if the number is not a three digit number with the first digit larger than the third, an error message must be printed to the console and the program terminated.

A typical session will otherwise be as follows. The number regarded as a decimal string is reversed, and the reverse subtracted from the original. You do not have to convert it to a String to achieve this. Details of the sum are displayed as indicated. Similarly, the result of the subtraction has its reverse added to it, and details of that sum are displayed as indicated. Then the program terminates.

Note that numbers should be always be reversed as if they have three digits, so e.g. 99 should be treated as 099 and its reverse will be 990.

$ java Rev 351

Reverse and subtract:

 351

 153 -

 ---

 198

 

Reverse and add:

 198

 891 +

 ---

1089

$

Hint.First write a static method that reverses a three digit number producing a result as described above, and test it directly from the main method. Your static method should have the following signature.

private static int reverse3(int i)

Reference no: EM13881626

Questions Cloud

Explain how to handle exceptions within a program : Continuing our discussion of exceptions we will work to understand various debugging and exception handling techniques. Please respond to all of the following prompts: -- Explain how to handle exceptions within a program, and provide an example using..
Method of getting around the old regulation : Coal containing 5.0 wt% S is burned at a rate of 1250lbm/mm in a boiler furnace. All of the sulfur in the coal is oxidized to SO2. The product gas is sent to a scrubber in which most of the SO2 is removed, and the scrubbed gas then passes out of a..
Explains to your friend about excitatory neurotransmitters : Write an essay that explains to your friend about excitatory neurotransmitters. Provide a detailed description of the functions associated with acetylcholine versus dopamine that could help differentiate which neurotransmitter is involved
Write an advanced java program for the game blackjack : Write an advanced java program for the game blackjack according to the following below data flow diagram
Reverses a three digit number producing a result : Hint.First write a static method that reverses a three digit number producing a result as described above, and test it directly from the main method. Your static method should have the following signature.
The total of the sale proceeds was credited : The total of the sale proceeds was credited to the investment account.
Calculate the heat required to raise : Calculate the heat required to raise 50 kg of solid sodium carbonate (Na2CO3) from 10°C to 50°C at 1atm using
Create a class called bankaccount : For your new program (#5 above), create a class called BankAccount. The BankAccount class should contain a String to store the customer name and a double to store the account balance. The BankAccount class should have two constructors, as follows:
The investment over the book value of net assets : 1.Fizer Pharmaceutical paid $68 million on January 2, 2013, for 4 million shares of Carne Cosmetics common stock.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd