Semester Programming Project This program should illustrate and simulate the ethical issue of the tragedy of the commons. In essence, it is a…

Semester Programming Project

This program should illustrate and simulate the ethical issue of the tragedy of the commons. In essence, it is a software toy that permits users to examine the balance between choices that benefit the individual but cost society versus those that benefit society at a cost to the individual.

Don't use plagiarized sources. Get Your Custom Essay on
Semester Programming Project This program should illustrate and simulate the ethical issue of the tragedy of the commons. In essence, it is a…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

The program can be written in either Java or C. Students have broad discretion with regards to implementation.

Quick overview.

Please consider creating an array (or linked list) of objects. Each object might have an integer ID, a Boolean switch (selfish or not-selfish), and a happiness score (integer). Then use the object in part A. Finally, implement part B representing the society.

Part A.

The first part of the program will create a series of individuals (objects) who make decision that are either selfish or altruistic. Each object will make its decisions independently. Some objects may choose to always be selfish. Others will always be altruistic. And some might be random. Each object will have an identity (an integer is sufficient), and can generate its choice. Each object will also have a score for happiness, which can change.

The program should be able to create from 1 to 20 (or more, if you prefer) individuals according to the user’s preference.

The program should be able to run multiple iterations (each with the same individuals), and be capable of up to 20 (or more, if you prefer) iterations, with output for each iteration.

When an individual is selfish, they gain 5 happiness points. When they are altruistic, they lose 2 happiness points.

When Part B is done, the government score will be added to the functionality of Part A.

Part B.

The second part will incorporate an entity called “government”, which will represent the aggregate effects of individual decisions by the individual objects.

If all individuals choose to be altruistic, society will benefit, but all of the individuals will be poor. If all individuals choose to be selfish, the individuals may do well, but society will be miserable. And if some number of individuals are altruistic and others are selfish, a balance might be achieved. The balance could be optimized, providing results for the number of objects with various characteristics.

If there are more selfish individuals than altruistic individuals, the government score is a negative number equal to the net number of selfish individuals (selfish – altruistic).

If there are an equal number of selfish and altruistic individuals, the government score is a zero.

If there are more altruistic individuals than selfish individuals, the government score is a positive number equal to the net number of altruistic individuals. (Altruistic – selfish).

These results are added to the individual happiness scores specified in Part A.

So if an individual is selfish, they would add 5 happiness points. If there are then 15 selfish people and 5 altruistic people, the government would subtract 10 points from each individual. Thus the selfish person would end up with -5 points. The altruistic person would end up with a -12 points for that round!

In contrast, suppose all 20 are altruistic. The government would add 20 points, the individuals would have negative scores as individuals, but the aggregate result is that each would add 18 points to their happiness score.

Punishment

The government can punish excessive selfishness. If an individual is selfish AND the government score is positive (more altruists than selfish), there is a 10% chance that a selfish individual will receive a punishment – in this case, a penalty of 50 points. Think of it as time in jail.

If an individual is selfish and the government score is negative (more selfish than altruists), there is a 50% chance that a selfish individual will receive a punishment – in this case, a penalty of 75 points. In other words, a long time in jail.

Note: These numbers are purely arbitrary. Feel free to experiment with other numbers!

Expert Answer

 package sample;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import java.util.Scanner;

class individuals
{
private int ID;
private boolean switchValue; // false then altruists else it will selfish
private int happiness_Score;
public individuals(int iD, boolean switchValue, int happiness_Score) {
super();
ID = iD;
this.switchValue = switchValue;
this.happiness_Score = happiness_Score;
}
public int getID() {
return ID;
}
public void setID(int iD) {
ID = iD;
}
public boolean isSwitchValue() {
return switchValue;
}
public void setSwitchValue(boolean switchValue) {
this.switchValue = switchValue;
}
public int getHappiness_Score() {
return happiness_Score;
}
public void setHappiness_Score(int happiness_Score) {
this.happiness_Score = happiness_Score;
}

}

public class Programming {
private ArrayList<individuals> li = new ArrayList<individuals>();
private static int idValue=1;
Scanner sc = new Scanner(System.in);
private void createObjects()
{
int iteration = sc.nextInt();

for(int i=0;i<iteration;i++)
{
Random rand = new Random();

int n = rand.nextInt(1);
if(n==0)
{
individuals e = new individuals(idValue,false,0);
li.add(e);
}
else
{
individuals e = new individuals(idValue, true, 0);
li.add(e);
}
idValue++;
}

}

private void iteration()
{
for(int i=0;i<20;i++)
{
Random rand = new Random();

int sValue = rand.nextInt(1);
int person = rand.nextInt(20) + 1;
if(sValue==0)
{
for(individuals d : li)
{
if(d.getID() == person )
{
d.setHappiness_Score(d.getHappiness_Score() – 2);
break;
}
}

}
else
{
for(individuals d : li)
{
if(d.getID() == person )
{
d.setHappiness_Score(d.getHappiness_Score() + 5);
break;
}
}
}
}
}
private int incorporate()
{
int selfish = 0;
int altruistic = 0;
for(individuals d : li)
{
if(d.isSwitchValue() == true )
{
selfish++;
}
else
altruistic++;
}
int govtScore = altruistic – selfish;

return govtScore;
}

public static void main(String []args)
{
Programming pObj = new Programming();
int governmentScore = pObj.incorporate();

pObj.createObjects();
pObj.iteration();

for(int i=0;i<pObj.li.size();i++)
{
if(governmentScore > 0 && pObj.li.get(i).isSwitchValue() == true) // If an individual is selfish AND the government score is positive (more altruists than selfish)
{
System.out.println(“10% chance of receiving punishment and penalty is 50 points.”);

}
else if(pObj.li.get(i).isSwitchValue() == true && governmentScore < 0)
{
System.out.println(“50% chance of receiving punishment and penalty is 75 points.”);
}
else
{
System.out.println(“Long term jail for you.”);
}
}

}

}

//output:

Top Grade Homework
Order NOW For a 10% Discount!
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents