Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.Write program that prompts the user to enter a three-digit whole number such that the digits are in ascending order and without duplicates. Valid examples:

1.Write program that prompts the user to enter a three-digit whole number such that the digits are in ascending order and without duplicates.

Valid examples: 123 and 489

Invalid examples: 133 and 174

The program loops and re-prompts the user until a correct value is entered. Make sure to check whether the user entered the correct data type.

Example Run:

Please enter a 3-digit integer: 122

Your number contains duplication.

Please enter a 3-digit integer: 1234

Error: You did not enter a 3-digit number.

Please enter a 3-digit integer: 1.23

Error: This is not an integer. Please re-enter.

Please enter a 3-digit integer: 376

Error: The digits are not in ascending order.

Please enter a 3-digit integer: 348

Number Accepted!

Chapter 6 Exercise

2.Create test file with a single sentence of twenty words.

Read the file, insert appropriate new line characters ( ) and write the test to a new text file that contains four lines of five words.

Print an error message and stop if the sentence in the file has other than twenty words.

Test the input file for existence and not crash if the file does not exist.

Chapter 14 Exercise

3.Create text file containing student records by line and each record is of the format:

Name of Student

Student ID

GPA

For example (you can use your own examples):

Tyrion Lannister, 1, 3.7

Daenerys Targaryen, 52, 2.8

Jon Snow, 13, 3.9

Sansa Stark, 24, 3.4

Write program to read the file line by line and store all the records in lists or tuples.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions