· web viewprinted codes at your lab teacher's office). answer your homework in computer...

5
Princess Nora Bint Abdulrahman University CS 141: Computer Programming 1 Faculty of Computer and Information Sciences Homework #2-(Iteration statement) Department of the Computer Sciences First Semester 1433/1434H Name: ID : Section: Answer these questions and submit it to your Lab teacher in ( MONDAY 12 /1/1434 H ) Instructions: 1. Submit your homework in both softcopy (on CD ) and hardcopy (printed codes at your Lab teacher's office). 2. Answer your homework in computer typed form. ANY handwritten answers will NOT be accepted. 3. ANY late homework for ANY excuses will NOT be accepted . 1

Upload: vutruc

Post on 14-Mar-2018

217 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: · Web viewprinted codes at your Lab teacher's office). Answer your homework in computer typed form. ANY handwritten answers will NOT be accepted. ANY late homework for ANY excuses

Princess Nora Bint Abdulrahman University CS 141: Computer Programming 1 Faculty of Computer and Information Sciences Homework #2-(Iteration statement)Department of the Computer Sciences First Semester 1433/1434H

Name: ID: Section:

Answer these questions and submit it to your Lab teacher in ( MONDAY 12 /1/1434 H )

Instructions:

1. Submit your homework in both softcopy (on CD) and hardcopy (printed codes at your Lab teacher's office).2. Answer your homework in computer typed form. ANY handwritten answers will NOT be accepted.3. ANY late homework for ANY excuses will NOT be accepted.

1

Page 2: · Web viewprinted codes at your Lab teacher's office). Answer your homework in computer typed form. ANY handwritten answers will NOT be accepted. ANY late homework for ANY excuses

Princess Nora Bint Abdulrahman University CS 141: Computer Programming 1 Faculty of Computer and Information Sciences Homework #2-(Iteration statement)Department of the Computer Sciences First Semester 1433/1434H

1. Write a C++ program that converts uppercase letters to their corresponding telephone digits . The program should reads the letter 'A' through 'Z' and print the corresponding telephone digit. To stop the program, the user is prompted for the sentinel. which is '#' .

Sample Run:

*****************Telephone Digits*****************Program to convert uppercase letters to their corresponding telephone digits.To stop the program enter #.Enter a letter: S

The letter you entered is SThe corresponding telephone digit is :7

Enter another uppercase letter to find its corresponding telephone digit. To stop the program enter #.Enter a letter: @

Invalid input

Enter another uppercase letter to find its corresponding telephone digit. To stop the program enter #.Enter a letter: A

The letter you entered is AThe corresponding telephone digit is :2

Enter another uppercase letter to find its corresponding telephone digit. To stop the program enter #.Enter a letter: #

Thank you .

2

Page 3: · Web viewprinted codes at your Lab teacher's office). Answer your homework in computer typed form. ANY handwritten answers will NOT be accepted. ANY late homework for ANY excuses

Princess Nora Bint Abdulrahman University CS 141: Computer Programming 1 Faculty of Computer and Information Sciences Homework #2-(Iteration statement)Department of the Computer Sciences First Semester 1433/1434H

2.Write a C++ program that reads in the side of a square and prints the square out of asterisks. Your program should work for square of all sizes between 1 and 20, when the user enter other sizes the program should display an error message.

Sample Run 1:

Enter the square side: 5*************************

Sample Run 2:

Enter the square side:21invalid input. the side of a square should be between 1 and 20.

3

Page 4: · Web viewprinted codes at your Lab teacher's office). Answer your homework in computer typed form. ANY handwritten answers will NOT be accepted. ANY late homework for ANY excuses

Princess Nora Bint Abdulrahman University CS 141: Computer Programming 1 Faculty of Computer and Information Sciences Homework #2-(Iteration statement)Department of the Computer Sciences First Semester 1433/1434H

4