Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!