Question

In: Computer Science

In this Java lab, you use the flowchart and pseudocode found in the figure below to...

In this Java lab, you use the flowchart and pseudocode found in the figure below to add code to a partially created Java program. When completed, college admissions officers should be able to use the Java program to determine whether to accept or reject a student, based on his or her test score and class rank. Declare the variables testScoreString and classRankString. Write the interactive input statements to retrieve: A student’s test score (testScoreString) A student's class rank (classRankString) Write the statements to convert the string representation of a student’s test score and class rank to the integer data type (testScore and classRank, respectively).

  1. Declare the variables testScoreString and classRankString.
  2. Write the interactive input statements to retrieve:
    • A student’s test score (testScoreString)
    • A student's class rank (classRankString)
  3. Write the statements to convert the string representation of a student’s test score and class rank to the integer data type (testScore and classRank, respectively).

Solutions

Expert Solution

these are there few line of code as per your requirements: Taking input interactively from user in string form and converting the string representation into integer data type.

Raw_code:

import java.util.Scanner; // import java utility Scanner for user input
import java.lang.NumberFormatException; // import NumberFormatException for Invalid user input
// driver class
public class rank{
// main method
public static void main(String[] args){
// creating object of Scanner
Scanner snr = new Scanner(System.in);
// declaring required variables for storing user input
String testScoreString, classRankString;
// variables for storing user input into integer type
int testScore = 0, classRank = 0;
// asking user to enter the TestScore
System.out.print("Enter the TestScore : ");
// using nextLine() method of Scanner object to read input String
// and storing it in testScoreString
testScoreString = snr.nextLine();
// asking user to enter the classRank
System.out.print("Enter the ClassRank : ");
// using nextLine() method of Scanner object to read input String
// and storing it in testScoreString
classRankString = snr.nextLine();
// try statement to catch invalid user input
try{
// converting String to integer type by using parseInt method in Integer wrapper class
testScore = Integer.parseInt(testScoreString);
classRank = Integer.parseInt(classRankString);
}
// catch statement to catch NumberFormatException
catch (NumberFormatException err){
System.out.println("Invalid input!");
// exiting program
System.exit(0);
}
// printing output for debugging
System.out.println("TestScore : " + testScore + ", ClassRank : "+ classRank);
}
}


Related Solutions

Please I can get a flowchart and a pseudocode for this java code. Thank you //import...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import java.util.Scanner; ;//import Scanner to take input from user public class TestScore {    @SuppressWarnings("resource")    public static void main(String[] args) throws ScoreException {//main method may throw Score exception        int [] arr = new int [5]; //creating an integer array for student id        arr[0] = 20025; //assigning id for each student        arr[1] = 20026;        arr[2] = 20027;...
I needv pseudocode and a flowchart for the following java code public class AcmePay { public...
I needv pseudocode and a flowchart for the following java code public class AcmePay { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int hours, shift, retirement = 0; do { System.out.print("Enter the number of hours worked (>0): "); hours = scanner.nextInt(); } while (hours <= 0); do { System.out.print("Enter shift [1 2 or 3]: "); shift = scanner.nextInt(); } while (shift < 1 || shift > 3); if (shift == 2 || shift ==...
Write the Flowchart for the following programming problem based on the pseudocode below. Last year, a...
Write the Flowchart for the following programming problem based on the pseudocode below. Last year, a local college implemented rooftop gardens as a way to promote energy efficiency and save money. Write a program that will allow the user to enter the energy bills from January to December for the year prior to going green. Next, allow the user to enter the energy bills from January to December of the past year after going green. The program should calculate the...
Homework Arrays and Tables In this assignment you are to create an algorithm, flowchart, and pseudocode...
Homework Arrays and Tables In this assignment you are to create an algorithm, flowchart, and pseudocode for a solution of the following problem. This solution will include the use of arrays needed to complete all parts of the logic. You have requested to develop a program that will record and process the rainfall totals of a 12 month period. You would use an array to store each months total. Once all 12 months amounts are entered then your solution need...
Selection/Conditional Structure: Create a flowchart and pseudocode for the problem below: Juan dela Cruz Restaurant is...
Selection/Conditional Structure: Create a flowchart and pseudocode for the problem below: Juan dela Cruz Restaurant is offering a 20% discount to all customers whose last name is also dela Cruz. Input the last name of the customer and the total amount due to the customer and then output the amount to be paid. (C++ Program, choose only the LAST NAME)
-Draw a flowchart and pseudocode for a program that produces a monthly bill for a cell...
-Draw a flowchart and pseudocode for a program that produces a monthly bill for a cell phone customer. -List at least 10 separate modules that might be included. - For example, one module might calculate the charge for daytime phone minutes used. - -Make a working version of this program using Python. Need all of the above answered including the correct code for program using python
A coin is sitting on a record as sketched in the figure below. It is found...
A coin is sitting on a record as sketched in the figure below. It is found that the coin slips off the record when the rotation rate is 0.42 rev/s. What is the coefficient of static friction between the coin and the record? the cd is 15 cm or .15 m
Searching an Array for an Exact Match in Java Summary In this lab, you use what...
Searching an Array for an Exact Match in Java Summary In this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten Java program. The program uses an array that contains valid names for 10 cities in Michigan. You ask the user of the program to enter a city name; your program then searches the array for that city name. If it is not found, the program should print...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the following requirements: Reads in a series of positive integers,  one number at a time;  and Calculate the product (multiplication) of all the integers less than 25,  and Calculate the sum (addition) of all the integers greater than or equal to 25. Use 0 as a sentinel value, which stops the input loop. [ If the input is 0 that means the end of the input list. ]...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT