You operate several news paper stands distributed throughout town. Define a clas
ID: 3673915 • Letter: Y
Question
Explanation / Answer
/********************************* NewsPaperStand.java ********************/
import java.util.*;
import java.io.*;
public class NewsPaperStand
{
int news_paper_Stand_ID; // news paper in particular stand
int news_paper_sold; // news paper from particular stand sold
static int total_paper_sold; // total papers sold
NewsPaperStand( int news_paper_Stand_ID, int news_paper_sold)
{
this.news_paper_Stand_ID = news_paper_Stand_ID;
this.news_paper_sold = news_paper_sold;
}
void oneSold (int news_paper_sold)
{
news_paper_sold++;
total_paper_sold++;
}
int paper_sold()
{
return news_paper_sold;
}
static int total()
{
return total_paper_sold;
}
public static void main(String[] args)
{
int paper_in_Stand1;
int paper_in_Stand2;
int paper_in_Stand3;
int total;
System.out.println(" ");
NewsPaperStand Stand1 = new NewsPaperStand(1,10);
paper_in_Stand1 = 10;
System.out.println("Stand 1 contain "+ paper_in_Stand1+" NewsPapers");
System.out.println("1 news paper from Stand 1 sold");
Stand1.oneSold(paper_in_Stand1);
System.out.println("NewsPaper in Stand 1 left are 9 ");
NewsPaperStand Stand2 = new NewsPaperStand(2,20);
paper_in_Stand2 = 20;
System.out.println("Stand 2 contain "+ paper_in_Stand2+" NewsPapers");
System.out.println("1 news paper from Stand 2 sold");
Stand2.oneSold(paper_in_Stand2);
System.out.println("NewsPaper in Stand 2 left are 19 ");
NewsPaperStand Stand3 = new NewsPaperStand(3,30);
paper_in_Stand3 = 30;
System.out.println("Stand 3 contain "+ paper_in_Stand3+" NewsPapers");
System.out.println("1 news paper from Stand 3 sold");
Stand3.oneSold(paper_in_Stand3);
System.out.println("NewsPaper in Stand 3 left are 29 ");
System.out.println("total papers sold are "+ NewsPaperStand.total());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.