top of page

Psychology Experiment Code

import java.util.Scanner;

 

public class PhysicsPsych {

     public static void main( String [] args ) {

 

          Scanner input = new Scanner( System.in );

 

          System.out.println();

          System.out.println( "Please enter a number from 1-10, but not 7:" ); //randomizing 

 

          int scen = input.nextInt();

          System.out.println();

 

          switch(scen) { //proposes scenarios and asks their opinion or directs them to redirect

               case 1:

               case 4:

               case 8:

                    System.out.println( "A train is headed for four people. To stop the train, a person                         pushes somebody in front, killing them but saving multiple lives." );

                    System.out.println();

                    System.out.println( "Were their actions morally acceptable? Enter 1 for yes and 2 for                       no.");

                    break;

               case 2:

               case 5:

               case 9:

                    System.out.println( "A train is headed for four people. To stop the train, a person                         releases a trap door which drops somebody in front of the train, killing them but saving                     multiple lives." );

                    System.out.println(); 

                    System.out.println( "Were their actions morally acceptable? Enter 1 for yes and 2 for                       no.");

                    break;

               case 3:

               case 6:

               case 10:

                    System.out.println( "A train is headed for four people. To stop the train, a person                         pulls a lever, which drops a weight which releases the latch holding a trap door closed,                     dropping a person into the path of the train, killing them, but saving multiple lives."                     );

                    System.out.println(); 

                    System.out.println( "Were their actions morally acceptable? Enter 1 for yes and 2 for                       no.");

                    break;

               default:

                    System.out.println( "Please ask for assistance to reset this program" );

          }

 

 

          int answer = input.nextInt(); 

 

          System.out.println(); //spacing

 

          if (answer == 1) //restating for my ease in recording

               System.out.println( "You said their actions were morally acceptable.");

          else 

               System.out.println( "You said their actions were not morally acceptable.");

 

          System.out.println(); //spacing

 

          System.out.println( "Thank you for your input!" );

 

          System.out.println();

 

     }

 

}

Happiness Video

bottom of page