Question

In: Computer Science

Write a program to determine if the student has passed the test or not. Please use...

  1. Write a program to determine if the student has passed the test or not. Please use two if statements to display the results.

For example, if the user has entered ‘true’, display ‘the student has passed the test’, and if the user has entered ‘false’, display ‘the student has failed the test’.

  1. Use the scanner class to get the Boolean datatype answer from the user if the student has passed the test or not.
  2. Use two if statements to determine if the student has passed or not.
    1. First if statement should use the conditional operator (== operator) to determine if the Boolean entry is ‘true’ and display saying that ‘the student has passed the test’.
    2. First if statement should use the conditional operator ( != operator) to determine if the Boolean entry is ‘ not true’ and display saying that ‘the student has failed the test

Solutions

Expert Solution

CODE :

import java.util.Scanner;
public class Main
{
   public static void main(String[] args) {
System.out.print("Did the student pass the test ? true or false ?");
Scanner obj = new Scanner(System.in);
boolean x = obj.nextBoolean();
if (x == true)
{
System.out.println("The student has passed the test");
}
else if (x != true)
{
System.out.println("The student has failed the test");
   }
   }
}


Related Solutions

c++ please 1. Write and test the function maximum that is passed an array of n...
c++ please 1. Write and test the function maximum that is passed an array of n pointers to integers and returns the maximum value among the n integers. The function must use the travellingpointer(1stversion) notation to traverse the array. The function has the following prototype. int maximum ( int *p [ ], int n); 2. Implement the function psum( )that is passed an array of n floats and returns a pointer to the sum of such an array. Print the...
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Code in C# please. Write a program that will use the greedy algorithm. This program will...
Code in C# please. Write a program that will use the greedy algorithm. This program will ask a user to enter the cost of an item. This program will ask the user to enter the amount the user is paying. This program will return the change after subtracting the item cost by the amount paid. Using the greedy algorithm, the code should check for the type of bill. Example: Cost of item is $15.50 User pays a $20 bill $20...
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students...
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below. Then, write methods for: Computing the...
use linux or c program. please provide the answer in details. Write a program that will...
use linux or c program. please provide the answer in details. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally...
Please write in python Use modular design to write a program that asks the user to...
Please write in python Use modular design to write a program that asks the user to enter his or her weight and the name of a planet. The program then outputs how much the user would weigh on that planet. The following table gives the factor by which the weight must be multiplied for each planet. PLANET CONVERSION FACTOR Mercury 0.4155 Venus 0.8975 Earth 1.0000 Moon 0.1660 Mars 0.3507 Jupiter 2.5374 Saturn 1.0677 Uranus 0.8947 Neptune 1.1794 Pluto 0.0899 The...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else statement logic​​​​​​​​​ b)​Write a Matlab program for sensor selection of temperature, pressure, flow sensor with if-else statement logic​​​​​​​​​ ​ 2.​Assume there are four letters from an information source with probabilities as A1 0.5 A2 0.3 A3 0.1 A4 0.1 Generate the tag and find the corresponding gaps and binary values for each stage and the sequence of the symbols which are coded are a1a3a2a4a1.​​​...
Write a program that calls a/few function(s) to determine the smaller of two arguments. Test the...
Write a program that calls a/few function(s) to determine the smaller of two arguments. Test the program using integer, character and floating-point number arguments. Produce 3 separate programs solving the problem above. The three approaches you should be using are: a) 3 different functions (findMinimum1(), findMinimum2(), findMinimum3()), each to solve different data types parameters. b) Function overloading with only one function named findMinimum( ) c) Function template with only one function named findMinimum( )
PLEASE DESCING A FLOWCHART IN FLOWGORITHM Test Average and Grade Write a program that asks the...
PLEASE DESCING A FLOWCHART IN FLOWGORITHM Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter grade for each the five test score and the average test score. Design the following functions in the program : -calAverge This function should accept five test scores as arguments and return the average of the scores. -determineGrade This function should accept a test score as an argument and return a letter...
Code in C++ please You are going to write a program for Computer test which will...
Code in C++ please You are going to write a program for Computer test which will read 10 multiple choice questions from a file, order them randomly and provide the test to the user. When the user done the program must give the user his final score
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT