Create file lab7.java with a main method.

Assignment Help JAVA Programming
Reference no: EM13163642

Part 1: Objects and Class Headers

Create file Lab7.java with a main method. Inside your main method, write a segment of code which instantiates an object of the Student class (This class has been created for you in the Student.java file that is provided as part of this lab).

Now, for the Student object you created, set its name and age as your own name and age. Next, we will print the Student details by calling thetoString method.

Hint: Below is a segment of code, which sets the name and age of Student

Student stInstance = new Student("Eric",28);

Next, prompt the user to enter a new age. Store the input in the variablenewAge.

Use the setAge method to set the age of stInstance to the age that you just read from the user. The user should receive the following prompt and the inputs should be stored into newAge.

"Please enter student's new age: "

Next, display the Student details again, and note how the age has been changed.

 

// The Student.java file is this:

/*

 

/**
** Do NOT edit this file!!
**/
// This is the class header for the class Student
public class Student
{
        // Declaring the variables
        private String name;
        private int age;

        // Declaring the constructor for the Student class
        public Student(String someName, int someAge)
        {
                name=someName;
                age=someAge;
        }

        // Declaring the toString method which returns a String representation of the object.
        public String toString()
        {
                return ("Name is \t:"+name+"\nAge is \t\t:"+age);
        }

        // Declaring the setAge method which sets the age of the Student object
        public void setAge(int newAge)
        {
                age= newAge;
        }

}

*/

 

 

Reference no: EM13163642

Questions Cloud

Boolean algebraic multiple choice question : boolean algebric mulitiple choice question
What are the requirements regarding plaintext and ciphertext : Keeping the IV secret in OFB mode does not make an exhaustive key search more complex. Describe how we can perform a brute-force attack with unknown IV. What are the requirements regarding plaintext and ciphertext?
Given a set of integer numbers : Given a set of integer numbers as int A[ ] = { 12, 6, 51, 4, 3, 7, 19, 8, 0, 21}, please write down the divide and conquer procedure of quick sort (step by step), include all left and right positions adjustment, and overwriting.
Windows application that function like a banking account : Create a Windows application that function like a banking account register. Separate the business logic from the presentation layer. The graphical user interface should allow user to input the account name, number, and balance.
Create file lab7.java with a main method. : Create file Lab7.java with a main method. Inside your main method, write a segment of code which instantiates an object of the Student class (This class has been created for you in the  Student.java  file that is provided as part of this lab).
Testing a program based on varying : Testing a program based on varying input values without knowing what the code looks like is called _____.With _____ testing, you make sure that every instruction in the code is executed at least once.
Write a program that checks if left and right braces : Write a program that checks if left and right braces, brackets, and parentheses are balanced
Program that compares the number of possible sequences : Write a c++ program that compares the number of possible sequences of the length L that can be generated. The program must output a formatted list comparing the number of possible sequences for L=5,6,7,8,9. given size N=9
Program that displays the ball at a random : Write a C++ program that displays the ball at a random location and then makes the ball move down to the bottom of the screen. When the ball reaches the bottom of the screen, it should start these actions over again, appear-ing at another random l..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Develop parent lock method asks for four digit password

Develop the parent lock method (turns lock on/off) which asks for 4 digit password. Navigating to any channel which is in range 99-110 must ask for password when parent lock is on.

  Design and implementation of a hangman game

Design and Implementation of a Hangman game

  Write java applet for costco gas station

Write a java applet for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use: grade 87, 89, or 91.

  Implement an intrusion detection system in java

You are to implement an intrusion detection system in java. Calculate a threshold for detecting an intrusion. The threshold is 2*(Sums of weights).

  Write a complete java program assuming that the variables gp

Write a complete java program Assuming that the variables gpa, deanList and studentName have been declared, you should read in the studentName and gpa from keyboard. Write an if statement that adds 1 to deansList and prints studentName to the standar..

  Program to find maximum-minimum of sequence of values

Common task which should be done in loop is to find maximum and minimum of sequence of values. File Temps.java contains program which reads in sequence of hourly temperature readings over 24- hour period.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Java program to write-read data from user using i-o function

Write java program to write and read data from user using I/O functions. Describe class with data members name[20],emp_id,basic pay,net pay.calculate all the allowances.

  Write a java binary search tree program

write a JAVA binary search tree program

  Write jvm program which accepts rpn expression

Write down the IJVM program which accepts RPN expression, with each operand and operator entered line by line. As each number (operand) is entered, push it on stack.

  Develop java code to compute monthly rent for housing units

Develop a java code that computes monthly rent for 3 housing units namely Bungalows,Apartments and hostels. All housing units have got size,color and monthly rental rate.

  Display student details and classes in applet

Display student details and classes they have enrolled in Applet. The Applet should have following features. Update and View.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd