Given an int variable grade, based on its value, assign a char variable letterGrade in the following way: 90 and above, ‘A’, 80 ~89, ‘B’, etc in java.
import java.util.Scanner; public class LetterGrade { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter score: "); int value = in.nextInt(); char letterGrade; if (value >= 90) { letterGrade = 'A'; } else if (value >= 80) { letterGrade = 'B'; } else if (value >= 70) { letterGrade = 'C'; } else if (value >= 60) { letterGrade = 'D'; } else { letterGrade = 'F'; } System.out.println("grade is " + letterGrade); } }
Given an int variable grade, based on its value, assign a char variable letterGrade in the...
Assume that an int variable takes 4 bytes and a char variable takes 1 byte. Given the following integer array: int arr[5] = {12, 10, 13, 90, 1}; Explain the value of arr .
Write a Java program: Given an int array grades int[] grades={89, 80, 78, 60, 38, 92, 72, 88}, find how many “B” among these grades, (80<=B<90) Print out how many “B”s in this grade.
Test Scores and Grade Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test scores and the letter grade that is assigned for the test score average. Use the grading scheme in the following table: Test Score Average Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D Below 60...
Given the following program: #include <stdio.h> struct student { int id; char name[20]; char grade; }; void func(struct student stud); int main() { struct student astud; astud.id=9401; strcpy(astud.name, "Joe"); astud.grade = 'A'; func(astud); return 0; } Abdelghani Bellaachia, CSCI 1121 Page: 16 void func(struct student astud) { printf(" Id is: %d \n", astud.id); printf(" Name is: %s \n", astud.name); printf(" Grade is: %c \n", astud.grade); } Modify this program to include the address of a student as a separate structure....
def computeGrade(percentage): ''' - Return the corresponding letter grade string based on the value of percentage using the following scale: [100 - 90]: 'A' (90 - 80] : 'B' (80 - 70] : 'C' (70 - 60] : 'D' (60 - 0] : 'F' - If percentage is not a number type (int or float) OR if percentage is outside the range of [100 - 0], return an empty string...
MATLAB Code: ?MATLAB Code: Write a function that converts a given letter grade it will print its equivalence in numerical scale. For example if the user enters A, then your function should print a message stating that the grade must be between 90 and 100. B is between 80 and 89, etc. Everything under 60 is F. Use the switch-case function. Use fprintf to display the results on the screen.
1. Given the array grade created as: int [] grade = {75, 80, 67, 95, 98, 88}; Fill in the following table with the required information. What is the value of grade.length ? _________ What is the value of grade[1] ? _________ 2. Write a get method (also known as a accessor method) for the hasNotPaid attribute.
Write Java statements that swap the element at the position given by the int variable index with the element that is two positions to its left in an array of char values called myChars. Use an if – else statement to make sure that this operation is possible (i.e. that all indexes are valid) and if not outputs a warning message.
#include <stdio.h> int main(int argc, char *argv[]) { char a, *pc, c[9]; int i, *pk, k[9]; a='z'; pc=&(c[8]); pk=&(k[0]); for (i=0; i<9; i++) { *pc=a-(char)i; pc--; *pk=(int)a-i; pk++; } return 0; }//end of main Answer the below questions with the above code Write out the memory map for the above C code in the following table. For array variables, list the address range for the entire array. Assume the memory address starts from 100, that is, the address for a...
Below is a java program that inputs an integer grade and turns it into a letter grade. Update the below java code as follows and comment each line to explain what is happening: 1. Convert the if-else-if code block to a switch statement to solve the problem. 2. Use modulus to convert the grade input so that the range of grades are converted to one value. (comment the line) import java.util.Scanner; public class GradeLetterTest { public static void main(String[] args)...