Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4) Write a function that takes the values of a two-card blackjack hands as input

ID: 3758328 • Letter: 4

Question

4) Write a function that takes the values of a two-card blackjack hands as input, and returns the point total of the hand. The value
of the cards '2' through '9' is equal to their face value, the cards 'T', 'K', 'Q', 'J' are worth 10 points and the ace ('A') is worth 11 points
unless it comes with another ace, then that second ace is worth 1 point. The program should be able to catch incorrect input.

Enter cards: A Q
The score is 21

Enter cards: A A
The score is 12

Enter cards: T 7
The score is 17

Enter cards: A 5
The score is 16

Enter cards: 7 #
*** Would be invalid, # is not a valid card

Enter cards: Z 4
*** Would be invalid, Z is not a valid card

Hint: I've used a value of 'T' for the 10 card so you can simply pass in two characters,
instead of strings, as parameters to this function.

5) Write a function to determine is a given word is legal. A word is illegal if it contains no vowels. For this problem,
the letter Y is considered to be a legal vowel. Pass in a word to this function and it will determine if the word is
legal or not. You can make the following assumptions about the word you a passing to this function.

1) The string being passed is a combination of letters only (no non-letter check needed)
2) The string being passed is null terminated
3) Letters may be capital or lower case and it has no effect on whether its a word

Examples:   

sch - is illegal, no vowels   
apple - legal, contains a vowel
APPle - legal, uppercase letter combinations do not matter
try - legal, no vowel, but contains the letter 'y'

Explanation / Answer

Answer :

4)

5)

#include <stdio.h>
#include <ctype.h>
#include <string.h>

_Bool isLegal(char word[100]);

int main(void)
{

char word[80];
int legalword;

   scanf("%s", word);


   legalword = isLegal(word);

   printf("%s is a legal word? ==>%i ", word,legalword);

   return 0;
}


_Bool isLegal (char mynewword[80])
   {
       int i;
       _Bool logo = 0;

      
       for (i = 0; mynewword[i] != "" && logo == 0; i++)

           {
          
           mynewword[i] = toupper(mynewword[i]);

           switch (mynewword[i])
               {
               case 'A':
               case 'E':
               case 'I':
               case 'O':  
               case 'U':
               case 'Y':
                   logo= 1;
                   break;
               default:
                   logo= 0;
                   break;
               }

           }

       return(logo); // return the result 1 = true, 0 = false
   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote