Question

In: Computer Science

Write a simple Java program that does the following: 1) Declare a constant of type String...

Write a simple Java program that does the following:
1) Declare a constant of type String to hold the words "Oakland University".
2) Declare variables of the type stated, and Prompt the user to enter in the following information and store in the variables
a. Their current GPA on a 4.0 scale, into a variable of type double
b. The number of credits they have so far into a variable of type int
c. The amount of tuition they paid so far into a variable of type int
d. Their last name, into a String variable
e. Their first initial, into a char variable
3) Create a variable of type char. Determine and assign a letter grade to it using the following rules and if else statement. (Note: this is not our class grading scheme.)
a. gpa < 1 F
b. 1 <= gpa < 2.5 D
c. 2.5 <= gpa < 3 C
d. 3 <= gpa <= 3.5 B
e. 3.5 < gpa <= 4 A

4) Create a variable of type double. Cast the either of the variables tuition or credits to
double to calculate the tuition dollars per credit hour and assign it to the new variable. .
5) Print out to the system console a single String using escape characters that outputs
multiple lines with the following information, formatted the same as this example. In
other words, the first column should indicate what is being output, and the second column
shows the value. Use variable names in your output String, not literals. You can use tab
escape characters to set up the second column.
a. your first initial and last name, with a period and space following your first initial
(from problem 2)
b. your university (from problem 1)
c. your Letter GPA grade (from problem 3)
d. Your tuition cost per credit hour (from problem 4)

Solutions

Expert Solution

import java.util.Scanner;

public class StudentCred {
   public static void main(String[] args) {
       final String unName = "Oakland University";
       Scanner sc = new Scanner(System.in);
       //reading gpa
       System.out.println("Enter gpa:");
       double gpa = sc.nextDouble();
       //reading credits
       System.out.println("Enter number of credits: ");
       int credits = sc.nextInt();
       //reading fee
       System.out.println("Enter total tution fee: ");
       int tutionFee = sc.nextInt();
       //reading name
       System.out.println("Enter lastName: ");
       String lastName = sc.nextLine();
       lastName = sc.nextLine();
       //reading initial
       System.out.println("Enter initial: ");
       char initial = sc.next().charAt(0);
       char grade;
       //finding grade
       if (gpa < 2.5)
           grade = 'D';
       else if (gpa >= 2.5 && gpa < 3)
           grade = 'C';
       else if (gpa >= 3 && gpa <= 3.5)
           grade = 'B';
       else
           grade = 'A';
       //finding fee
       double dollorsPerCredit = tutionFee / (double) credits;
       System.out.println("Name : " + lastName + "." + initial);
       System.out.println("University Name :" + unName);
       System.out.println("GPA grade: " + grade);
       System.out.println("Tution cost per credit hour: " + dollorsPerCredit);

   }
}

Note : If you like my answer please rate and help me it is very Imp for me


Related Solutions

Write a java code segment to declare an array of size 10 of type String and...
Write a java code segment to declare an array of size 10 of type String and read data for them from a file, prompt user for the file name. Data is stored in a file with 1 string per line.
A) Declare a String variable called myString0 and initialize it to "Java". B) Declare a String...
A) Declare a String variable called myString0 and initialize it to "Java". B) Declare a String variable called myString1 and initialize it to "Programming". C) Declare a String variable called myString2 and initialize it to "Language". D) Print the concatenation of myString0 + " is a " + myString1 + " " + myString2 + ".". E) Print the sum of the lengths of myString1 and myString2 (must call the length() method). F) Print the 2nd, 4th, and 7th character...
Write a program in java processing. Write a program that does the following: · Assume the...
Write a program in java processing. Write a program that does the following: · Assume the canvas size of 500X500. · The program asks the user to enter a 3 digit number. · The program then checks the value of the first and last digit of the number. · If the first and last digits are even, it makes the background green and displays the three digit number at the mouse pointer. · If the two digits are odd, it...
Write a program in c++ to do the following : (1) Declare an array a of...
Write a program in c++ to do the following : (1) Declare an array a of size 10 and three pointer variables p, q, and v. (2) Write a loop to fill array a with values 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 (3) write following statement: p= &a[2]; q = &a[5]; i = *q - *p; cout<<“The value of i is”<< i; i = *p - *q; cout<<“The value of i is %d”<< i; 4) assign...
Write a JAVA program that reads in a string from standard input and determines the following:...
Write a JAVA program that reads in a string from standard input and determines the following: - How many vowels are in the string (FOR THE PURPOSE OF THIS PROGRAM 'Y' is NOT considered a vowel)? - How many upper case characters are in the string? - How many digits are in the string? - How many white space characters are in the string? - Modify the program to indicate which vowel occurs the most. In the case of a...
in. java Write a program that reads a string from the user, and creates another string...
in. java Write a program that reads a string from the user, and creates another string with the letters from in reversed order. You should do this using string concatenation and loops. Do not use any method from Java that does the work for you. The reverse string must be built. Do not just print the letters in reversed order. Instead, concatenate them in a string. --- Sample run: This program will create a string with letters in reversed order....
Write a simple MIPS program that asks the user to input a string and then a...
Write a simple MIPS program that asks the user to input a string and then a character. The program should then count how many times that character appears in the string and print out that value. Please use comments.
Write a Java program that takes in a string and a number and prints back the...
Write a Java program that takes in a string and a number and prints back the string from the number repeatedly until the first character... for example Pasadena and 4 will print PasaPasPaP. Ask the user for the string and a number Print back the string from the number repeatedly until the first character For both programs please utilize: methods arrays loops Turn in screenshots
Write a Java program that prompts the user to input a word (String). The program must...
Write a Java program that prompts the user to input a word (String). The program must print the reversed word with all consecutive duplicate characters removed. The program must contain the following classes: - The StackX class (you can use the Java Stack class). - The Reverse class which must contain a private data field called “word” of type string, a constructor, and a void method called revNoDup(). The revNoDup() method must reverse the word and remove the consecutive duplicate...
I want to write this program in java. Write a simple airline ticket reservation program in...
I want to write this program in java. Write a simple airline ticket reservation program in java.The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT