Question

In: Computer Science

Create a Project and a Class called “FinalGrade” Write a Java program to compute your final...

  1. Create a Project and a Class called “FinalGrade”

Write a Java program to compute your final grade for the course.

Assume the following (you can hard-code these values in your program).

Assignments are worth 30%

Labs are worth 40%

Mid-term is worth 15%

Final is worth 15%

Ask for the grades in each category. Store them in a double variable.
Print out the final percentage grade.

          For example,

Final Grade Calculation

Enter percentage grades in the following order.

Assignments, Labs, Mid-term test, Final Exam: 95 88 86 92

The final grade is 90

2. Create a Project and a Class called “AgeCheck”

Write a Java program to ask the user for their name and age. Use a string variable for the name and an int variable for the age. Output a message using the name and whether the user is old enough to purchase alcohol (21 years old).

For example,

Age Checker
Enter your name: Steve
Enter your age: 19
Hello, Steve, you are only 19 and not old enough to purchase alcohol.

Age Checker
Enter your name: Jane
Enter your age: 25
Hello, Jane, you are 25 and old enough to purchase alcohol.

Solutions

Expert Solution

Program 1:

import java.util.Scanner;           //scanner class importing

public class FinalGrade  

{

public static void main(String args[])           //main function

   {

   double assignments,labs,mid,final_exam;       //variables for storing grades which are double data type

   Scanner input=new Scanner(System.in);                   //creating scanner class input object
  
   System.out.println("Enter Percentage Grade of Assignments");
  
   assignments=input.nextDouble();                       //asking user to enter assignment grades
  
   System.out.println("Enter Percentage Grade of Labs");
  
   labs=input.nextDouble();                   //askin user to enter labs grades
  
   System.out.println("Enter Percentage Grade of Mid-term Test");
  
   mid=input.nextDouble();           //asking user to enter mid term test grades
  
   System.out.println("Enter Percentage Grade of Final Exam");
  
   final_exam=input.nextDouble();       //asking user to enter final_Exam grades
  
   double final_grade=(0.3*assignments)+(0.4*labs)+(0.15*mid)+(0.15*final_exam);
  
   //finally computing final grade by multiplying each grade with their worth % here 30% can be written as 30/100 i.e 0.3
  
   System.out.println("The Final Grade is " + (int)(final_grade)); //at the end printing the final grade by casting it to int
  
   }
}


Program 2:

import java.util.Scanner;           //scanner class importing

public class AgeChecker

{

   public static void main(String args[])           //main function

       {

           Scanner input=new Scanner(System.in);       //scanner class input object creation

           System.out.println("Age Checker");

           String name;                   //name variable which is string data type

           int age;                   //age variable which is int data type

           System.out.print("Enter Your Name : ");

           name=input.nextLine();               //asking user to enter the name

           System.out.print("Enter Your Name : ");

           age=input.nextInt();           //asking user to enter the age

           if (age>=21)           //if age greater than or equal to 21 print below message

               System.out.println("Hello, "+name+", you are "+ age +" and old enough to purchase alcohol.\n");

           else //else print not old enough to purchase alcohol

               System.out.println("Hello, "+name+", you are only "+ age +" and not old enough to purchase alcohol.\n");
       }
}


Program 1 Code and Output Screenshots:

Program 2 Code and Output Screenshots :

Note : if you have any queries please post a comment thanks a lot..always available to help you...


Related Solutions

This is a Java program assignment. In the GradeCalculator class, compute the final average and letter...
This is a Java program assignment. In the GradeCalculator class, compute the final average and letter grade for a particular student. The final average is calculated according to the following rules: 1) There are ten exams scored out of 100 points 2) The lowest exam score is not included in the calculation of the final average 3) The highest exam score is not included in the calculation of the final average 4) An average of 91-100 is an A 5)...
LANGUAGE: JAVA Create a New Project called YourLastNameDomainName. Write a DomainName class that encapsulates the concept...
LANGUAGE: JAVA Create a New Project called YourLastNameDomainName. Write a DomainName class that encapsulates the concept of a domain name, assuming a domain name has a single attribute: the domain name itself. Include the following: - Constructor: accepts the domain name as an argument. - getDomain: an accessor method for the domain name field. - setDomain: a mutator method for the domain name field. - prefix: a method returning whether or not the domain name starts with www. - extension:...
Create a Java project called Lab3B and a class named Lab3B. Create a second new class...
Create a Java project called Lab3B and a class named Lab3B. Create a second new class named Book. In the Book class: Add the following private instance variables: title (String) author (String) rating (int) Add a constructor that receives 3 parameters (one for each instance variable) and sets each instance variable equal to the corresponding variable. Add a second constructor that receives only 2 String parameters, inTitle and inAuthor. This constructor should only assign input parameter values to title and...
Create a Java project called Lab3A and a class named Lab3A. Create a second new class...
Create a Java project called Lab3A and a class named Lab3A. Create a second new class named Employee. In the Employee class: Add the following private instance variables: name (String) job (String) salary (double) Add a constructor that receives 3 parameters (one for each instance variable) and sets each instance variable equal to the corresponding variable. (Refer to the Tutorial3 program constructor if needed to remember how to do this.) Add a public String method named getName (no parameter) that...
Create a Java project called 5 and a class named 5 Create a second new class...
Create a Java project called 5 and a class named 5 Create a second new class named CoinFlipper Add 2 int instance variables named headsCount and tailsCount Add a constructor with no parameters that sets both instance variables to 0; Add a public int method named flipCoin (no parameters). It should generate a random number between 0 & 1 and return that number. (Important note: put the Random randomNumbers = new Random(); statement before all the methods, just under the...
Create a new Java project called lab1 and a class named Lab1 Create a second class...
Create a new Java project called lab1 and a class named Lab1 Create a second class called VolumeCalculator. Add a static field named PI which = 1415 Add the following static methods: double static method named sphere that receives 1 double parameter (radius) and returns the volume of a sphere. double static method named cylinder that receives 2 double parameters (radius & height) and returns the volume of a cylinder. double static method named cube that receives 1 double parameter...
In Java Create a class called "TestZoo" that holds your main method. Write the code in...
In Java Create a class called "TestZoo" that holds your main method. Write the code in main to create a number of instances of the objects. Create a number of animals and assign a cage and a diet to each. Use a string to specify the diet. Create a zoo object and populate it with your animals. Declare the Animal object in zoo as Animal[] animal = new Animal[3] and add the animals into this array. Note that this zoo...
Write in Java * Create a new client class called Plants.java * Write code in the...
Write in Java * Create a new client class called Plants.java * Write code in the Plants class that solves problems 1,2,3 and 4 * Include the solutions of the different problems in different methods and call them from the main method * Use the BagInterface.java and ArrayBag.java, but do not add any code Problem 1: Create a bag plantsCart, which holds the following spring seedlings(represented by String) Rose, Daisy, Cabbage, Cucumber, Carrot, Cucumber, Daffodil, Daisy, Rose, Iris, Rose, Spinach....
The following program will be written in JAVA. Create a class called complex performing arithmetic with...
The following program will be written in JAVA. Create a class called complex performing arithmetic with complex numbers. Write a program to test your class.                         Complex numbers have the form:                         realPart + imaginaryPart * i                                               ___                         Where i is sqrt(-1)                                                 Use double variables to represent data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in...
JAVA program Create a class called Array Outside of the class, import the Scanner library Outside...
JAVA program Create a class called Array Outside of the class, import the Scanner library Outside of main declare two static final variables and integer for number of days in the week and a double for the revenue per pizza (which is $8.50). Create a method called main Inside main: Declare an integer array that can hold the number of pizzas purchased each day for one week. Declare two additional variables one to hold the total sum of pizzas sold...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT