Docsity

Object-Oriented Programming Exercises: Input/Output and Currency Conversion, Quizzes of Object Oriented Programming

Toggle sidebar
bg1
3.31 (Financials: currency exchange) Write a program that prompts the user to enter
the exchange rate from currency in U.S. dollars to EGP. Prompt the user to enter 0 to
convert from U.S. dollars to EGP and 1 to convert from EGP to U.S. dollars. Prompt the
user to enter the amount in U.S. dollars or EGP to convert it to EGP or U.S. dollars,
respectively. Here are the sample runs:
Enter the exchange rate from dollars to EGP: 15.73
Enter 0 to convert dollars to EGP and 1 vice versa: 0
Enter the dollar amount: 100
$100.0 is 1573.0 egp
Enter the exchange rate from dollars to EGP: 15.73
Enter 0 to convert dollars to EGP and 1 vice versa: 1
Enter the EGP amount: 1000
1000.0 egp is $63.65
5.47 (Business: check ISBN-13) ISBN-13 is a new standard for identifying books. It
uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d12d13. The last digit d13 is a checksum, which is
calculated from the other digits using the following formula:
10 - (d1 + 3d2 + d3 + 3d4 + d5 + 3d6 + d7 + 3d8 + d9 + 3d10 + d11 + 3d12)%10
If the checksum is 10, replace it with 0. Your program should read the input as a
string. Here are sample runs:
Enter the first 12 digits of an ISBN-13 as a string: 978013213080
The ISBN-13 number is 9780132130806
Enter the first 12 digits of an ISBN-13 as a string: 978013213079
The ISBN-13 number is 9780132130790
Enter the first 12 digits of an ISBN-13 as a string: 97801320
97801320 is an invalid input
5.48 (Process string) Write a program that prompts the user to enter a string and
displays the characters at even positions. Here is a sample run:
Enter a string: Beijing Chicago
Ejnhcg
Arab Academy for Science, Technology & Maritime Transport
College of Computing and Information Technology
Course: Object-Oriented Programming
Lecturer: Dr.Fahima Maghraby, Dr. Emad Elsamahy, Dr. Yasser Omar, Dr. Shereen Ahmed
Teaching Assistant: Eng.Maiada, Eng. Nada, Eng.Hagar, Eng.Alaa
Sheet: Section 1 Input/Output
1
pf2

Partial preview of the text

Download Object-Oriented Programming Exercises: Input/Output and Currency Conversion and more Quizzes Object Oriented Programming in PDF only on Docsity!

3.31 (Financials: currency exchange) Write a program that prompts the user to enter the exchange rate from currency in U.S. dollars to EGP. Prompt the user to enter 0 to convert from U.S. dollars to EGP and 1 to convert from EGP to U.S. dollars. Prompt the user to enter the amount in U.S. dollars or EGP to convert it to EGP or U.S. dollars, respectively. Here are the sample runs: Enter the exchange rate from dollars to EGP: 15. Enter 0 to convert dollars to EGP and 1 vice versa: 0 Enter the dollar amount: 100 $100.0 is 1573.0 egp Enter the exchange rate from dollars to EGP: 15. Enter 0 to convert dollars to EGP and 1 vice versa: 1 Enter the EGP amount: 1000 1000.0 egp is $63. 5.47 (Business: check ISBN-13) ISBN-13 is a new standard for identifying books. It uses 13 digits d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 8 d 9 d 10 d 11 d 12 d 13. The last digit d13 is a checksum, which is calculated from the other digits using the following formula: 10 - (d 1 + 3d 2 + d 3 + 3d 4 + d 5 + 3d 6 + d 7 + 3d 8 + d 9 + 3d 10 + d 11 + 3d 12 )% If the checksum is 10, replace it with 0. Your program should read the input as a string. Here are sample runs: Enter the first 12 digits of an ISBN-13 as a string: 978013213080 The ISBN-13 number is 9780132130806 Enter the first 12 digits of an ISBN-13 as a string: 978013213079 The ISBN-13 number is 9780132130790 Enter the first 12 digits of an ISBN-13 as a string: 97801320 97801320 is an invalid input 5.48 (Process string) Write a program that prompts the user to enter a string and displays the characters at even positions. Here is a sample run: Enter a string: Beijing Chicago Ejnhcg Arab Academy for Science, Technology & Maritime Transport College of Computing and Information Technology Course: Object-Oriented Programming Lecturer: Dr.Fahima Maghraby , Dr. Emad Elsamahy, Dr. Yasser Omar, Dr. Shereen Ahmed Teaching Assistant: Eng.Maiada, Eng. Nada, Eng.Hagar, Eng.Alaa Sheet: Section 1 Input/Output 1

2