# Problem: Compare student marks
# Input: mark1 as an integer from 0 to 100
# Input: mark2 as an integer from 0 to 100
mark1 = 99
mark2 = 97
# Output: answer, a string
if mark1 == mark2 :
answer = 'Both marks are same'
if mark1 == mark1 - 1
answer = 'First mark is one less than second'
if mark2 == mark2 - 1
answer = 'Second mark is one less than first'
if (mark1 - mark2 > 1) or (mark2 - mark1 > 1) :
answer = 'Marks differ by more than 1'
print(answer)
Question 1: what are the admissible values for the inputs?
b)
i ) What are the syntax errors in this program? Consider no other errors at this point.
mark1 = 99
mark2 = 97
# Output: answer, a string
if mark1 == mark2 :
answer = 'Both marks are same'
if mark1 == mark1 - 1 #this line contains syntax error
answer = 'First mark is one less than second'
if mark2 == mark2 - 1 #this line contains syntax error
answer = 'Second mark is one less than first'
if (mark1 - mark2 > 1) or (mark2 - mark1 > 1) :
answer = 'Marks differ by more than 1'
print(answer)
#int, float, double values are acceptable
#correct code is
mark1 = 99
mark2 = 97
# Output: answer, a string
if mark1 == mark2 :
answer = 'Both marks are same'
if mark1 == mark1 - 1:
answer = 'First mark is one less than second'
if mark2 == mark2 - 1:
answer = 'Second mark is one less than first'
if (mark1 - mark2 > 1) or (mark2 - mark1 > 1) :
answer = 'Marks differ by more than 1'
print(answer)

# Problem: Compare student marks # Input: mark1 as an integer from 0 to 100 #...
Part I Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be handled...
Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...
static public int[] Question() // retrieve an integer 'n' from the console // the first input WILL be a valid integer, for 'n' only. // then read in a further 'n' integers into an array. // in the case of bad values, ignore them, and continue reading // values until enough integers have been read. // this question should never print "Bad Input" like in lab // hint: make subfunctions to reduce your code complexity return null; static public int...
UNIX QUESTION Exercise #1. [8 Marks] Create a script that does the following: a. Takes 4 input parameters b. Using the shell special variables print the following: i. The command you executed ii. First input iii. Second input iv. Third input v. Fourth Input vi. Process Id vii. Total number of input parameters [ by querying the system for it ] Exercise #2. [8 Marks] Creates a script that does the following: a. Takes two input parameters b. Using the...
6.6 LAB: Exception handling to detect input String vs. IntegerThe given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented. The program fails and throws an exception if the second input on a line is a String rather than an Integer. At FIXME in the code, add a try/catch statement to catch java.util.InputMismatchException, and output 0 for the age.Ex: If the input is:Lee 18 Lua 21 Mary Beth 19 Stu 33 -1then the output...
The language is Python and there is more than one input.
Instructions from your teacher: Instructions Prompt for a string and cut it into two "equal" parts (If the length of the string is odd, place the center character in the first string, so that the first string contains one more characther than the second). Print a new string on a single row with the first and second halfs interchanged (second half first and the first half second) Don't use...
Java code
ABOVE AVERAGE 40 Input Standard input Output Standard output Topic Array & Array Processing Problem Description Understanding how to interpret test scores is a valuable skill for every teacher. That's because test score interpretation enables teachers to understand how their students' performance for each tests of the course. Average test score is one of the indicators to determine the class performance for the test. For each test, we need to calculate the average score and determine the percentage...
b) (2.5 marks) Write a Matlab user defined function that takes the letter grades (i.e. AABBC) as input and returns if the student entitled to the honor list or not. The student is considered in the honor s f he or she satisfies the following three conditions: a. An average GPA of 3.5 and above and b. At least two classes with A mark and e. no class with a mark less than C (i.e. no D or F) The...
The method generate() will produce integer arrays of a random size between 10 and 20 members. The method print() will print out the members of an integer array input. The method insert() will accept two arrays as inputs. It will produce a new array long enough to contain both arrays, and both input arrays should be inserted into the new array in the following manner: select a random member of the first array, and insert every member of the second...
3. Write Python statements that will do the following: a) Input a string from the user. *** Print meaningful messages along with your output.* b) Print the length of the String. Example input: The sky is blue. Correct output: The length of the string is 16 Incorrect output: 16 c) Print the first character of the string. d) Print the last character of the string. 4. Save the program. Double-check the left edge for syntax errors or warning symbols before...