Purchase Solution

Java: Program to remove comma from the number

Not what you're looking for?

Ask Custom Question

Write a Java program that reads a number between 1,000 and 999,999 from the user, where the user enters a comma in the input. Then it prints the number without a comma. Below is a sample dialog.

Please enter an integer between 1,000 and 999,999: 23,456
23456

Hint: Read the input as a string. Measure the length of the string. Suppose it contains n characters. Then extract substrings consisting of the first n - 4 characters and the last three characters.

Purchase this Solution

Solution Summary

The solution follows the hint provided in the posting. It accepts one number from the user and prints it after removing comma, if any, from it, and then exits.

Solution Preview

Please rename the attached 532817-RemoveComma.java to RemoveComma.java before you attempt to compile it. Java version "1.7.0_03" was used during the development of this program.

Attached solution follows the hint provided in the posting and has ...

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.