Question

i'm trouble getting my program to print this output and repeat until asked to quit the...

i'm trouble getting my program to print this output and repeat until asked to quit the program

Enter a telephone number using letterss (EXIT to quit): GET LOAN
The corresponding telephone number is:
438-5626

Here's my code:

#include <stdio.h>

#include <string.h>

char getNumber(char aC) {

char c = ' ';

switch (aC) {

case 'A':

case 'B':

case 'C':

c = '2';

break;

case 'D':

case 'E':

case 'F':

c = '3';

break;

case 'G':

case 'H':

case 'I':

c = '4';

break;

case 'J':

case 'K':

case 'L':

c = '5';

break;

case 'M':

case 'N':

case 'O':

c = '6';

break;

case 'P':

case 'Q':

case 'R':

case 'S':

c = '7';

break;

case 'T':

case 'U':

case 'V':

c = '8';

break;

case 'W':

case 'X':

case 'Y':

case 'Z':

c = '9';

break;

}

return c;

}

int main() {

char str[100];

char *uppr;

while(1){

printf("Enter a telephone number using letterss (EXIT to quit): The corresponding telephone number is: \n");

gets(str);

if(strcmp(str,"EXIT")==0)

break;

int i=0;

for(i=0;i<8;i++){

if(i==3){

printf("-");

}

if(str[i]==' ')

continue;

if(str[i]>='a' && str[i]<='z'){

str[i]=str[i]-32;

}

printf("%c\n",getNumber(str[i]));

}

}

return 0;

}

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

#include <stdio.h>

#include <string.h>

char getNumber(char aC) {

char c = ' ';

switch (aC) {

case 'A':

case 'B':

case 'C':

c = '2';

break;

case 'D':

case 'E':

case 'F':

c = '3';

break;

case 'G':

case 'H':

case 'I':

c = '4';

break;

case 'J':

case 'K':

case 'L':

c = '5';

break;

case 'M':

case 'N':

case 'O':

c = '6';

break;

case 'P':

case 'Q':

case 'R':

case 'S':

c = '7';

break;

case 'T':

case 'U':

case 'V':

c = '8';

break;

case 'W':

case 'X':

case 'Y':

case 'Z':

c = '9';

break;

}

return c;

}

int main() {

char str[100];

char *uppr;

while(1){

printf("\nEnter a telephone number using letterss (EXIT to quit): \n");

gets(str);

if(strcmp(str,"EXIT")==0)

break;

printf("The corresponding telephone number is:\n");

int i=0;

for(i=0;i<8;i++){

if(i==3){

printf("-");

}

if(str[i]==' ')

continue;

if(str[i]>='a' && str[i]<='z'){

str[i]=str[i]-32;

}

printf("%c",getNumber(str[i]));

}

}
printf("Bye Bye");
return 0;

}

Note : If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
i'm trouble getting my program to print this output and repeat until asked to quit the...
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
  • I'm having trouble getting a certain output with my program Here's my output: Please input a...

    I'm having trouble getting a certain output with my program Here's my output: Please input a value in Roman numeral or EXIT or quit: MM MM = 2000 Please input a value in Roman numeral or EXIT or quit: mxvi Illegal Characters. Please input a value in Roman numeral or EXIT or quit: MXVI MXVI = 969 Please input a value in Roman numeral or EXIT or quit: EXIT Illegal Characters. Here's my desired output: Please input a value in...

  • I'm having trouble getting my program to output this statement Enter a sentence: Test! There are...

    I'm having trouble getting my program to output this statement Enter a sentence: Test! There are 5 total characters. There are 1 vowel. There are 1 UPPERCASE letters. There are 3 lowercase letters. There are 1 other characters. Here's my code: #include<string.h> #include<stdio.h> #include<stdbool.h> int main() { char str[100]; int i; int vowels=0; int UC; int LC; int Others; int c; printf("Enter a sentence: \n"); gets(s); LC=countLC(&s); UC=countUC(&s); Others=countOthers(&s); printf("There are %d total characters.\n", ; for(i=0; i<strlen(str); i++){ if(isVowel(str[i])) vowels++;...

  • I'm having trouble getting my program to output What is your first name? damion what is...

    I'm having trouble getting my program to output What is your first name? damion what is your last name? anderson damion, Your first name is 6 characters Your last name, anderson, is 8 characters Your name in reverse is: noimad nosredna This is my code so far: #include <stdlib.h> #include <stdio.h> void sizeOfName(char** name); void printSizeOfName(int *first, int *last, char** name); void reverseString(int *first, int *last, char** name); int main() {   char** name;   name = (char**)malloc(2*sizeof(char*));   name[0] = (char*)malloc(100*sizeof(char));   name[1]...

  • Here is a serial program in C and parallel program in OpenMP that takes in a string as input and counts the number of occurrences of a character you choose. Why is the runtime for the output for the O...

    Here is a serial program in C and parallel program in OpenMP that takes in a string as input and counts the number of occurrences of a character you choose. Why is the runtime for the output for the OpenMP parallel program much longer? Serial Program #include <stdio.h> #include <string.h> #include <time.h> int main(){    char str[1000], ch;    int i, frequency = 0;    clock_t t; struct timespec ts, ts2;       printf("Enter a string: ");    gets(str);    int len = strlen(str);    printf("Enter a character...

  • #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here....

    #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } }    return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...

  • The following code is a C Program that is written for encrypting and decrypting a string....

    The following code is a C Program that is written for encrypting and decrypting a string. provide a full explanation of the working flow of the program. #include <stdio.h> int main() { int i, x; char str[100]; printf("\n Please enter a valid string: \t"); gets (str); printf ("\n Please choose one of the following options: \n"); printf ("1 = Encrypt the given string. \n"); printf("2 = Decrypt the entered string. \n"); scanf("%d",&x); // using switch case statements switch (x) {...

  • Language is in C. Need help troubleshooting my code Goal of code: * Replace strings with...

    Language is in C. Need help troubleshooting my code Goal of code: * Replace strings with a new string. * Append an s to the end of your input string if it's not a keyword. * Insert a period at the end, if you have an empty input string do not insert a period Problems: //Why does my code stop at only 2 input strings //If I insert a character my empty string case works but it's still bugged where...

  • I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int...

    I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int main() { char gender; float a1, a2, a3, a4, a5; float waistmeasurement, wristmeasurement, hipmeasurement, forarmmeasurement; float B, bodyweight, Bodyfat, Bodyfatpercentage;    printf("This program determines the body fat of a person.Enter your gender (f|F|m|M): "); scanf("%c", &gender); printf("\n");    if(gender=='F' || gender=='f'){ printf("Enter body weight (in pounds): \n"); scanf("%f", &bodyweight); printf("Enter wrist measurement at fullest point (in inches): \n"); scanf("%f", &wristmeasurement); printf("Enter waist measurement at...

  • I'm also having trouble on dividing the code into methods. This is my work done so...

    I'm also having trouble on dividing the code into methods. This is my work done so far and net beans give me a lot of errors. Help! package caesarcipher; import textio.TextIO; /** * * @author */ public class CaesarCipher { enum code {encodeText, decodeText }; /** * @param args the command line arguments */ public static void main(String[] args) {    String code; char x;    int totalcount = 0;    while(true){ TextIO.put("Type in an E to encode a message...

  • i'm having trouble making an else statement that will allow the program to add and output...

    i'm having trouble making an else statement that will allow the program to add and output the average the valid numbers inputed into the program. Here's my output: Enter Score 1:36 Enter Score 2:-1 Invalid Input Enter Score 2:89.5 Enter Score 3:42 Enter Score 4:66.3 Enter Score 5:93 You entered: 36.000000, 89.500000, 42.000000, 66.300000, 93.000000 Total Score: 362.800000 Average Score: 72.560000 Max Score: 93.000000 Min Score: 36.000000 Here's my code: #include <stdio.h> int main(void) { double score[5]; double min; double...

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
Active Questions
ADVERTISEMENT