Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

scanner detail: void Read(Scanner s) Read the contents of all member variables f

ID: 3639299 • Letter: S

Question

scanner detail: void Read(Scanner s) Read the contents of all member variables from the given instance of Scanner. Assume member variable values are separated by tabs.


public class MyDate
{
private int day;
private int month;
private int year;

public MyDate()
{
day = 1;
month = 1;
year = 2000;
}


public MyDate(int m, int d, int y)
{
day = m;
month = d;
year = y;
}

public int Getday() { return day; }
public int Getmonth() { return month; }
public int Getyear() { return year; }

public void Setday(int newday) { day = newday; }
public void Setmonth(int newmonth) { month = newmonth; }
public void Setyear(int newyear) { year = newyear; }

public void Write(PrintStream ps)
{
ps.printf("%d", "%d", "%d", day, month, year );
}

public void Read(Scanner s)
{

}
}

Explanation / Answer

please rate - thanks

import java.io.*;
import java.util.*;
public class MyDate
{
private int day;
private int month;
private int year;

public MyDate()
{
day = 1;
month = 1;
year = 2000;
}


public MyDate(int m, int d, int y)
{
day = m;
month = d;
year = y;
}

public int Getday() { return day; }
public int Getmonth() { return month; }
public int Getyear() { return year; }

public void Setday(int newday) { day = newday; }
public void Setmonth(int newmonth) { month = newmonth; }
public void Setyear(int newyear) { year = newyear; }

public void Write(PrintStream ps)
{
ps.printf("%d", "%d", "%d", day, month, year );
}

public void Read(Scanner s)
{System.out.print("enter month day year, separated by tabs: ");
month=s.nextInt();
day=s.nextInt();
year=s.nextInt();
}
}