Java+Chapter+2.1+Exercise+4


 * exercise number:Java Chapter 2.1 Exercise 4**

code An integer constant dayOfWeek1 has a value from 0 to 6 and represents the day of the week for January 1st (0=Sunday, 1=Monday, etc.). A variable day has a value from 1 to 31 and represents a day in January. Write an expression that calculates the day of the week for any given value of day. For example if dayOfWeek1= 0 (January 1st is a Sunday) and day = 13 (January 13th), then dayOfWeek, the day of the week for January 13th, should get a value of 5 (Friday). code
 * description of objective:**

**Code:** code format="java" import java.util.Scanner;

public class usingvariables4 { public static void main(String[] args) { Scanner in = new Scanner(System.in);

System.out.print("Enter a date in January: ");

int iput = in.nextInt;

if (iput > 7 && iput < 14) { System.out.print("The day of week is:"); System.out.print( iput - 8); }		if (iput > 14 && iput < 21) { System.out.print("The day of week is:"); System.out.print( iput - 15); }		if (iput > 21 && iput < 28) { System.out.print("The day of week is:"); System.out.print( iput - 22); }		if (iput > 28 && iput < 32) { System.out.print("The day of week is:"); System.out.print( iput - 29); }		if (iput < 7) { System.out.print("The day of week is:"); System.out.print( iput - 1); }		if (iput < 1 || iput > 31) { System.out.print("What the crap are you doing?"); } } } code