Question

Write a program that prompts the user to enter a 10 alphabets (A-Z) and converts it...

Write a program that prompts the user to enter a 10 alphabets (A-Z) and converts it to numbers using the following mapping:

A, B, C = 8

D, E, F = 6

G, H, I = 4

J, K, L = 5

M, N, 0 = 7

P, Q, R, S = 2

T, U, V, W = 3

X, Y, Z = 1

Please be sure to use Object Oriented Programming concepts when designing and writing code for this question. Complete class(es) (if more than > 1 class is required) and main() method is required.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <string>
using namespace std;


// Class Declaration
class alphabets {

public:
void inputprompt(char alpha[])
{   
//Get Input Values For Object Varibales
for(int i = 0; i < 10; i++){
cout << "Enter " << i << " alphabet (A-Z): ";
cin >> alpha[i];
}
}
  
void printing(char alpha[])
{   
//Print The number
for(int i = 0; i < 10; i++){
switch (alpha[i])
{
case 'A':
case 'B':
case 'C':
cout << 8 <<endl;
break;
case 'D':
case 'E':
case 'F':
cout << 6 <<endl;
break;
case 'G':
case 'H':
case 'I':
cout << 4 <<endl;
break;
case 'J':
case 'K':
case 'L':
cout << 5 <<endl;
break;
case 'M':
case 'N':
case 'O':
cout << 7 <<endl;
break;
case 'P':
case 'Q':
case 'R':
case 'S':
cout << 2 <<endl;
break;
case 'T':
case 'U':
case 'V':
case 'W':
cout << 3 <<endl;
break;
case 'X':
case 'Y':
case 'Z':
cout << 1 <<endl;
break;
}
}
}
  
};


//Main Function

int main() {
//Variable Declaration
char alpha[10];
  
// Object Creation For Class
alphabets o1, o2;

o1.inputprompt(alpha);
o2.printing(alpha);
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a program that prompts the user to enter a 10 alphabets (A-Z) and converts it...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds

    Problem 1.Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds. The program should use the convertMillismethod with the following header:public static String convertMillis(long millis)For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, andconvertMillis(555550000) returns the string154:19:10.Problem 2. (Count occurrence of numbers)Write a program that reads integers between 1 and 100 and counts the occurrence of each (you should store the numbers in an array). Output...

  • Exercise #3: write a Java program that prompts the user to enter a sentence. The program...

    Exercise #3: write a Java program that prompts the user to enter a sentence. The program has to find the print: a. the position of vowels in the sentence. b. the number of vowels in the sentence (A, a, U, u, E, e, O, o, I, i) c. the number of characters as numbers or special characters (other than English letters a.z, A..Z). Hint: remember to ignore the spaces. Sample input-output: Enter the sentnse: UAEU is the university of the...

  • 1. Write a program that prompts the user to enter three integers and display the integers...

    1. Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. You can assume that all numbers are valid. For example: Input Result 140 -5 10 Enter a number: Enter a number: Enter a number: -5, 10, 140 import java.util.Scanner; public class Lab01 { public static void main(String[] args) { Scanner input = new Scanner(System.in);    } } ---------------------------------------------------------------------------------------------------------------------------- 2. Write a program that repeatedly prompts the user for integer values from...

  • Program must be in Python 3. Write a program that prompts the user to enter two...

    Program must be in Python 3. Write a program that prompts the user to enter two strings and then displays a message indicating whether or not the first string starts with the second string. Your program must satisfy the following requirements. 1. Your program must include a function called myStartsWith that takes two string parameters. This function returns True if the rst string starts with the second string and returns False otherwise. 2. Your program must include a main function...

  • c++ please (1) Write a program that prompts the user to enter an integer value N...

    c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...

  • Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt,...

    Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt, and displays data for the specified record. If the record does not exist, display the following error message: No records found for p# using System; using static System.Console; using System.IO; class FindPatientRecords { static void Main() { // Your code here } }

  • Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt,...

    Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt, and displays data for the specified record. If the record does not exist, display the following error message: No records found for p# using System; using static System.Console; using System.IO; class FindPatientRecords { static void Main() { // Your code here } }

  • Steps: Write a program that upon getting mass value from user, converts it to energy using...

    Steps: Write a program that upon getting mass value from user, converts it to energy using Einstein’s mass-to-energy conversion equation. You must write a function to calculate energy. Writing the whole thing in main will not get any credit. Note: Conversion equation=> e = m x c^2 Please do these steps: 1-Draw flowchart diagram or write the pseudocode 2-Write your code 3-Run the code 4-Test for all possible inputs!

  • please use java Write a program that prompts the user to enter line of text (including...

    please use java Write a program that prompts the user to enter line of text (including whitespace). The program then replaces the following vocals with numbers: a = 1, e = 2, i = 3, o = 4, u = 5 and outputs the result to the console. The program does not consider case, so a = 1, A = 1, e = 2, E = 2, etc. Example: Input: Hello, how are you? Output: H2ll4, h4w 1r2 y45? The...

  • I need to Write a test program that prompts the user to enter 10 double values...

    I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT