Question

Correct the mistakes public class customer { public static void main(String[] args) { D customer=new d();...

Correct the mistakes public class customer { public static void main(String[] args) { D customer=new d(); d.employee(56,”ali”); d.department(7,8.6,9); } public void employee(String name, int age) { System.out.println("Your name is"+name); System.out.println(“Age is”+age); } public int department(double d, double t, int a) { System.out.println("I have java exam at 3:00"); Return(1.1); } } V. PROGRAMMING. Write a complete JAVA program to implement the following. 1. Create a class named Exponent. Its main() method accepts an integer value from a user at the keyboard, and in turn passes the value to a method that squares the number (multiplies it by itself) and to a method that cubes the number (multiplies it by itself twice). The main() method displays the results. Create the two methods that respectively square and cube an integer that is passed to them, returning the calculated value. Save the application as Exponent.java. 2. Create a class named Student. A student has fields for an ID number, name, course, number of credit hours earned, and number of points earned. Accept values to all fields. A student also has a field for grade point average. Include a method to compute a grade point average field by dividing points earned by credit hours earned. Write methods to display the values in each Student field. By declaring a student object from the class you created call all the methods in main method and display all results in your program.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*********************Customer.java************************/

public class Customer {
   public static void main(String[] args) {
       Customer d = new Customer();
       d.employee("ali", 56);
       d.department(7, 8.6, 9);
   }

   public void employee(String name, int age) {
       System.out.println("Your name is " + name);
       System.out.println("Age is " + age);
   }

   public int department(double d, double t, int a) {
       System.out.println("I have java exam at 3:00");
       return (int) (1.1);
   }
}

/****************output******************/

Your name is ali
Age is 56
I have java exam at 3:00

/*******************************Exponent.java**************************/

import java.util.Scanner;

public class Exponent {

   public static void main(String[] args) {

       // Scanner class is used to enter value from keyboard or user
       Scanner scan = new Scanner(System.in);
       System.out.print("Enter the value to find the square and cube: ");
       // save a value form user
       int value = scan.nextInt();
       // calling both method and save returned value
       int squaredValue = square(value);
       int cubeValue = cube(value);
       // print the information
       System.out.println("After Square: " + squaredValue);
       System.out.println("After Cube: " + cubeValue);
       scan.close();
   }

   // method square
   private static int square(int value) {
       return value * value;
   }

   // method cube
   private static int cube(int value) {
       return value * value * value;
   }
}
/***************output************************/

Enter the value to find the square and cube: 5
After Square: 25
After Cube: 125

/*****************************Student.java************************/


public class Student {

   // data field
   String id;
   String name;
   String course;
   int numberOfHoursCredit;
   int numberOfPoints;

   // constructor
   public Student(String id, String name, String course, int numberOfHoursCredit, int numberOfPoints) {
       super();
       this.id = id;
       this.name = name;
       this.course = course;
       this.numberOfHoursCredit = numberOfHoursCredit;
       this.numberOfPoints = numberOfPoints;
   }

   // To display the information
   public void displayInfo() {

       System.out.println("Student id: " + id);
       System.out.println("Student name: " + name);
       System.out.println("Studnet course: " + course);
       System.out.println("number of hours credit: " + numberOfHoursCredit);
       System.out.println("Number of Points Earned: " + numberOfPoints);
       System.out.println("Grade point Average: " + computeGradePointAvg());
   }

   // method to compute grade point average
   public double computeGradePointAvg() {

       return (double) numberOfPoints / (double) numberOfHoursCredit;
   }

   public static void main(String[] args) {

       Student student = new Student("ST101", "Ali", "CSE101", 5, 43);
       student.displayInfo();
   }

}
/*****************************output*************************/

Student id: ST101
Student name: Ali
Studnet course: CSE101
number of hours credit: 5
Number of Points Earned: 43
Grade point Average: 8.6

Please let me know if you have any doubt or modify the answer, Thanks and do not forget to thumbs up:)

Add a comment
Know the answer?
Add Answer to:
Correct the mistakes public class customer { public static void main(String[] args) { D customer=new d();...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {   ...

    import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {        Student s1 = new Student();         Student s2 = new Student("Smith", "123-45-6789", 3.2);         Student s3 = new Student("Jones", "987-65-4321", 3.7);         System.out.println("The name of student #1 is ");         System.out.println("The social security number of student #1 is " + s1.toString());         System.out.println("Student #2 is " + s2);         System.out.println("the name of student #3 is " + s3.getName());         System.out.println("The social security number...

  • This is for a java program public class Calculation {    public static void main(String[] args)...

    This is for a java program public class Calculation {    public static void main(String[] args) { int num; // the number to calculate the sum of squares double x; // the variable of height double v; // the variable of velocity double t; // the variable of time System.out.println("**************************"); System.out.println(" Task 1: Sum of Squares"); System.out.println("**************************"); //Step 1: Create a Scanner object    //Task 1. Write your code here //Print the prompt and ask the user to enter an...

  • For Java please.Artwork. javaimport java.util.Scanner;public class ArtworkLabel {public static void main(String[] args)...

     Given main(). define the Artist class (in file Artist java) with constructors to initialize an artist's information, get methods, and a printlnfo() method. The default constructor should initialize the artist's name to "None' and the years of birth and death to 0. printinfo() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise. Define the Artwork class (in file Artwork.java) with constructors to initialize an artwork's information, get methods, and a printinfo() method. The constructor should...

  • Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args)...

    Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args) { displayWelcomeMessage(); // create the Scanner object Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // generate the random number and invite user to guess it int number = getRandomNumber(); displayPleaseGuessMessage(); // continue until the user guesses the number int guessNumber = 0; int counter = 1; while (guessNumber != number) { // get a valid int from user guessNumber...

  • import java.util.Scanner; public class MPGMain {    public static void main(String[] args)    {       ...

    import java.util.Scanner; public class MPGMain {    public static void main(String[] args)    {        Scanner input = new Scanner(System.in);               Mileage mileage = new Mileage();               System.out.println("Enter your miles: ");        mileage.setMiles(input.nextDouble());               System.out.println("Enter your gallons: ");        mileage.setGallons(input.nextDouble());               System.out.printf("MPG : %.2f",mileage.getMPG());           } } public class Mileage {    private double miles;    private double gallons;    public double getMiles()...

  • What are the errors in this ? public class Mystery { public static void main(String[] args)...

    What are the errors in this ? public class Mystery { public static void main(String[] args) { double initialSavings = 10000; double interestRate = 0.05; double currSavings = 0; int i;    System.out.println("\nAnnual savings 5 years: "); currSavings = initialSavings; for (i = 0, i < 5, ++i); currSavings = (currSavings * interestRate); System.out.println("$" + currSavings); }    }

  • public class PracticeExam { public static void main(String[] args) { int[][] data = { { 0,...

    public class PracticeExam { public static void main(String[] args) { int[][] data = { { 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6 }, { 0, 1,...

  • import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {...

    import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {        String name;        String answer;        int correct = 0;        int incorrect = 0;        Scanner phantom = new Scanner(System.in);        System.out.println("Hello, What is your name?");        name = phantom.nextLine();        System.out.println("Welcome " + name + "!\n");        System.out.println("My name is Danielle Brandt. "            +"This is a quiz program that...

  • Need help with the program DemoSugarSmash.java import java.util.*; public class DemoSugarSmash { public static void main(String[]...

    Need help with the program DemoSugarSmash.java import java.util.*; public class DemoSugarSmash { public static void main(String[] args) { // Complete the demo program here } } PremiumSugarSmashPlayer.java public class PremiumSugarSmashPlayer { // Define the PremiumSugarSmashPlayer class here } PremiumSugarSmashPlayer.java public class SugarSmashPlayer { private int playerID; private String screenName; private int[] scoresArray ; public SugarSmashPlayer() { this.scoresArray = new int[10]; } public SugarSmashPlayer(int levels) { this.scoresArray = new int[levels]; } public int getIdNumber() { return playerID; } public void setIdNumber(int...

  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT