Question- How would I allow the program to run both upper and lower case letters. How would I write a switch statement for upper and lower cases to see if the value entered for Grade2 is a A or a?
C programming
int main()
{
char Grade2;
float gradepoint;
char Grade = 'X'; // Declares a character type variable named
Grade
printf("Enter a grade\t"); // Prompts for Grade
scanf("%c", &Grade); // Inputs Grade
printf("Grade is: \t%c\n", Grade); // Prints the value of
Grade
// Part 3 - using if else statements
if(Grade=='A')
{
printf("The Value of an A is 4.0");
}
else if(Grade=='B')
{
printf("The Value of a B is 3.0");
}
else if(Grade=='C')
{
printf("The Value of C is 2.0");
}
else if(Grade=='D')
{
printf("The Value of D is 1.0");
}
else if(Grade=='D')
{
printf("The Value of F is 0.0");
}
else if(Grade=='F')
{
printf("The value of <entered value of Grade> is not
defined");
}
// Part 4- using switch-case-break statements
fflush(stdin); //This clears the scanf buffer
printf("\nEnter Grade2\t");
scanf("%c", &Grade2);
printf("Grade2 is: \t%c\n", Grade2);
Make Grade2= 'A' //changes entry to upper case only
Make gradepoint= 4.0f // sets grade-point to 4.0 if grade is
'A'
Print"Grade2:<tab><value of grade2>has value
of<gradepoint formatted as 3.1>
getch();
return 0;
}
Below is the code for the above problem:
#include<stdio.h>
#include<stdlib.h>
int main()
{
char Grade2;
float gradepoint;
char Grade = 'X'; // Declares a character type variable named
Grade
printf("Enter a grade\t"); // Prompts for Grade
scanf("%c", &Grade); // Inputs Grade
printf("Grade is: \t%c\n", Grade); // Prints the value of
Grade
// Part 3 - using if else statements
if(Grade =='A' || Grade == 'a')
{
printf("The Value of %c is 4.0",Grade);
}
else if(Grade=='B' || Grade == 'b')
{
printf("The Value of %c is 3.0",Grade);
}
else if(Grade=='C' || Grade == 'c')
{
printf("The Value of %c is 2.0",Grade);
}
else if(Grade=='D' || Grade == 'd')
{
printf("The Value of %c is 1.0",Grade);
}
else if(Grade=='F' || Grade == 'f')
{
printf("The Value of %c is 0.0",Grade);
}
else
{
printf("The value of %c is not defined",Grade);
}
// Part 4- using switch-case-break statements
fflush(stdin); //This clears the scanf buffer
getchar();
printf("\nEnter Grade2\t");
scanf("%c", &Grade2);
printf("Grade2 is: \t%c\n", Grade2);
switch(Grade2)
{
case 'A':
case 'a': gradepoint = 4.0;
break;
case 'B':
case 'b': gradepoint = 3.0;
break;
case 'C':
case 'c': gradepoint = 2.0;
break;
case 'D':
case 'd': gradepoint = 1.0;
break;
case 'F':
case 'f': gradepoint = 0.0;
break;
default:
printf("The value of %c is not defined",Grade);
return 0;
}
printf("Grade2:\t%c has value of %0.1f\n",Grade2,gradepoint);
return 0;
}
OUTPUT:

Question- How would I allow the program to run both upper and lower case letters. How...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...
Identify and list all the User defined Functions to be used in the system #include <stdio.h> ///for input output functions like printf, scanf #include <stdlib.h> #include <conio.h> #include <windows.h> ///for windows related functions (not important) #include <string.h> ///string operations /** List of Global Variable */ COORD coord = {0,0}; /// top-left corner of window /** function : gotoxy @param input: x and y coordinates @param output: moves the cursor in specified position of console */ void gotoxy(int x,int y) {...
I need little help with C language. I need to pass what I get from HexToBin(char* hexdec) into char* input so that what I got there it should pass it as string array parametr. Example: Enter IEEE-Hex: 40200000 Equivalent Binary value is : 01000000001000000000000000000000 Decimal Number: 2.5 #include <stdio.h> void HexToBin(char* hexdec) { long int i = 0; while (hexdec[i]) { switch (hexdec[i]) { case '0': printf("0000"); break;...
I am trying to run this program in Visual Studio 2017. I keep getting this build error: error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". 1>Done building project "ConsoleApplication2.vcxproj" -- FAILED. #include <iostream> #include<cstdlib> #include<fstream> #include<string> using namespace std; void showChoices() { cout << "\nMAIN MENU" << endl; cout << "1: Addition...
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) {...
Write a C program that does the following: Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square,Diamond (with selected height and selected symbol), or Quits if user entered Q.Apart from these 2 other shapes, add a new shape of your choice for any related character. Program then prompts the user to enter a number and...
So I have a question in regards to my program. I'm learning to program in C and I was curious about the use of functions. We don't get into them in this class but I wanted to see how they work. Here is my program and I would like to create a function for each of my menu options. I created a function to display and read the menu and the option that is entered, but I would like to...
Programming in C: I am trying to modify this linked list to be doubly linked list. I’m also trying to add a print in reverse function. I’m really struggling with how to change the insert function to doubly link the nodes without effecting the alphabetical sorting mechanism. Example of desired output: Enter your choice: 1 to insert an element into the list. 2 to delete an element from the list. 3 to end. ? 1 Enter a character: a The...
Question 2 Use a switch statement to write the following program: Using C++ The program prompts the user for a letter grade (of type char). The list of valid letter grades is: A B C D E F The program should consider both lower and upper case The program will then display the following messages: For grade ‘A’: display “Excellent” For grade ‘B’: display “Good” For Grade ‘C’: display “Average” For grade ‘D’ or ‘E’: display “Below Average” For Grade...