QuestionQuestion

You are provided with the Student class, which consists of two private variables- name, age. It also contains a constructor, and two methods i.e. toString
// which will return the String representation of the Student object, and setAge which will set the Students age.

//Import the Scanner class.
//-->

//Write the class header for the file and the main method header.
public class Solution{

public static void main(String[] args){

//Instantiate an object of the Student class, called stInstance. Set the name and age as your own name and age. Use the constructor to do so.
??? ??? = new ???(???,???);

// Print the Student details by calling the toString method.
//-->

// Instantiate an object of the Scanner class.
//-->

System.out.print("Please enter the student's new age: ");

// Input the Students age from the user into a variable called newAge.
//->

// Use the setAge method, to set the age of stInstance to the age you just read in from the user.
???.setAge(???);

// Display the Student details again, and note how the age has been changed.
//-->

// Change the header for the Student class to private instead of public. Try to compile and run the program and note what happens.
//--> ****** This is an experiment (dont include it in your submission) *******

// Print Fibonacci Series i.e 1, 1, 2, 3, 5, 8, 13, 21, ...
// The formula is currVal= prevVal + prevPrevVal
// Define 3 integer variables currVal, prevVal and prevPrevVal. Initialize prevVal and prevPrevVal variables to 1
// and initialize currVal to 2
//-->

System.out.print("Fibonacci Series between 1 and 100: ");

// Print out prevVal
//-->

// Print out prevPrevVal
//-->

// Write a do-while loop to print out Fibonacci numbers less than or equals 100
???{

// Print out the <currVal>
//-->

// Assign <prevVal> to <prevPrevVal>
//-->

// Assign <currVal> to <prevVal>
//-->

// Calculate <currVal> using the formula given earlier
//-->

} // Check the while condition if <currVal> is less than or equals 100
???(???)

}
}

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Student {

private String name;
private int age;

public Student(String someName, int someAge)
{
name = someName;
age = someAge;
}

public String toString()
{
return ("Name is \t:" + name + "\nAge is \t\t:" + age);
}

public void setAge(int newAge)
{
age = newAge;
}

}...
$20.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats