Print out an error message that contains the first non-digit

Assignment Help JAVA Programming
Reference no: EM132109208

Programming Project

For this project you are to code two functions that accept C-string parameters.

bool allDigits(char str[])

This function accepts a C-string parameter (null-terminated char array) and return true if the C-string contains only digits. The function is to return false if the C-string contains any other character.

char *firstNonDigit(char str[])

This function accepts a C-string parameter and returns a pointer to the first non- digit that occurs in the string. If the string contains only digits, the function is to return the value null.

The main function for this project is to follow the indicated algorithm:

Repeat

Prompt for an int, read it into a Cstring

If the string contains any illegal (non-digit) characters

Print out an error message that contains the first non-digit of the input

Until a valid string (all digits) is entered

Convert the C-string to an int (the atoi function in the cstdlib library is

handy here)

Print out the int that was input, and also twice that value

You may find the cctype library, as discussed in Section 8.5 helpful in determining if a character is a digit. Alternatively, a digit is simply a character within the range ‘0' - ‘9'.

Reference no: EM132109208

Questions Cloud

What is a programming language : Answer the following Question : What is a programming language?
Demonstrate the class with a driver program : In a course, a teacher gives the following tests and assignments: A lab activity that is observed by the teacher and assigned a numeric score.
Write an m-file in matlab which can perform a word search : Convey how the program was developed, what issues were encountered, whether the program was successful (and if not, why not), etc.
Create a patron class for the library : The class will have a user's name. library card number, and library fees (if owed). Have functions that access this data, as well as a function to set the fee.
Print out an error message that contains the first non-digit : This function accepts a C-string parameter (null-terminated char array) and return true if the C-string contains only digits.
Write a public static method named static long tribonacci : Write a public static method named static long tribonacci(int n, long a, long b, long c)
Create an sql or access database with all your friends : Create an SQL or Access database with all your friends' information and write a program to load the names in the combo box and also search the database.
Summarize the recommended instructional strategies : Summarize and explain how you plan to involve Marias parents in meeting her goals. Include a specific at-home activity to help in her continued success
Write a public static method named static long : Write a public static method named static long fibFast(int n, long a, long b) that returns the nth fibonacci number.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Demonstrate the use of array or arraylist

It will calculate the additional amount of sales that each salesperson must achieve to match or exceed the higher of the two earners. The application should ask for the name of each salesperson being compared.

  Write a program counter.java that is a thread

Write a program Counter.java that is a Thread that counts up to a limit with random pauses in between each count.

  Define a car structure type

For this assignment you will write a program that determines which of a set of rental cars the user can rent for a user-specified rental rate. The rental car data is contained in a text file which will be fed into your program using stdin redirect..

  Write a jsp webpages ask the user to enter data

Write a jsp webpages ask the user to enter the following data- First name, Last name

  Write a complete java class called diffcubes

Write a complete Java class called DiffCubes that uses a Scanner reads in two int values from the console. Using these values, the program should find the difference between the cubes of the two values and write the result to the screen

  Describe different professional levels in this discipline

What is Anesthesiology and critical care medicine describe the specific discipline, what is their focus (i.e., emergency medicine, education and prevention, psychiatric treatment etc.) Describe the different professional levels in this discipline

  Create new bluej project and a new class named cashregister

Create a new BlueJ project and a new class named CashRegister. Write a program that allows the user to enter the quantity of pennies

  Creates an object of type fahrenheit

Creates an object of type Fahrenheit and an object of type Celsius - Accepts a single argument from the command line

  Calculate and display mortgage payments

Let the user decide on the down payment percentage amount to use. Calculate and display mortgage payments for both a 20-year and a 30-year loan, to allow the user to compare them.

  How large a value can be stored in an integer variable

Most programming languages have a built-in integer data type. Normally this representation has a fixed size, thus placing a limit on how large a value can be stored in an integer variable

  Concept of web based information system

Design and implement a simple and small email server using the concept of web based information system

  Adopting a working game of ping pong in java

Create a new Java project. You will be porting each of the classes from the example code to swing, so its better to code in empty class and fill in the details - Object-Oriented Design in Java

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