Assignment 9: Practice Projects Solution

$30.00

Category:

Description

Project 1:

 

Introduction: Cryptography is the science of making messages secure, of transforming readable messages into unreadable messages and back again. Messages that are unreadable are called ciphertext. The process of turning plaintext into ciphertext is called encryption. The reverse process of turning ciphertext into plaintext is called decryption. One of the easiest ways to encrypt a message is to scramble the letters. For example the word “apple” could be randomly transformed to “lapep” In fact there are 120 different possible arrangements of the word “apple.” However, if the encryption algorithm randomly scrambles the letters, the task of the decryption algorithm is hard. Encryption and decryption algorithms must work together in some agreed upon way, with the encryption algorithm scrambling letters and the decryption algorithm unscrambling them.

 

A transposition cipher is one way to scramble the letters of a message. The cipher separates the message into two groups of characters: the first group composed of the even-numbered characters and the second group composed of the odd-numbered characters. To produce the ciphertext, the cipher puts together both groups; placing the group of the even-numbered characters first, followed by the group of odd-numbered characters. This encryption results in a string with the characters shuffled to new positions.

 

 

  1. Ask user to enter a string. Write a function that takes the string as a parameter, encrypt the message as described above and returns the ciphertext. Then ask user again if she/he wants to continue or not. Finally print all the original messages in alphabetically ascending order.

 

Example:

 

Please enter a message: Fight, Matadors, for Tech! The encrypted message is: ih,Mtdr,frTc!Fgt aaos o eh Do you want to continue(Y/N)? Y

 

Please enter a message: Bear our banners far and wide.

 

The encrypted message is: erorbnesfradwd.Ba u anr a n ie

 

 

The original messages in alphabetical order are:

 

Bear our banners far and wide

 

Fight, Matadors, for Tech!

 

 

Project 2:

You will create an ATM menu specified below

 

  • Check balance

 

  • Make a Deposit
  • Make a Withdrawal
  • Change Password
  • Exit

Please type a number from 1 to 5 to select a menu item:

 

When a number is input by the user, you will print the string corresponding to the number and execute the task as shown below in the list. The underlined entity is the user input for each choice in the menu.

 

User entered 1
Execute Check balance
Balance is $ 153.80
User entered 2
Execute Make a Deposit
Enter amount to deposit: 54.77
New Balance is $ 208.57
User entered 3
Execute Make a Withdrawal
Enter amount to withdraw: 40.00
New Balance is $ 168.57
User entered 4
Execute Change Password
Enter new password: 99999999
New Password is “99999999”

 

 

User entered 5

Execute Exit

Terminating program

 

Have a nice day!

 

If the input number is 5, your program should terminate as shown above. Otherwise, after every transaction is completed you would print a new line

 

Press any key to continue your transactions …

 

Your program will wait until user presses any key on the keyboard. After a key is pressed, your program will display the menu as above and repeat the process above. Note in the process above, when a number is not in 1 to 5, you will ignore the input.

 

You will use getchar() to consume and putchar() to print the character entered by the user is a standard I/O (input/output) function with the following specification (slightly modified from its original specification)

 

 

Internally you will create the following variables and any others to hold needed information.

 

  • MyAccount-Store a float number
  • Initialize MyAccount to 1000.00 as initial balance
  • Password – Store an integer of length 8 digits
  • Initialize Password to 12345678
  • Char variable/s to hold user input and key press.
  • When 1) is pressed you will display contents of MyAccount
  • Deposit increments MyAccount
  • Withdrawal decrements MyAccount
  • When 5 is pressed you must exit cleanly from the Program

 

 

Write pseudocode to solve the given problems.

Write C program to solve the above problems. Name your file Lab9_YourName.c


error: Content is protected !!