Check06A - int value =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; import java.io.PrintStream; i public class Check06A { public static void main(String[] args) { PrintStream output = System.out; Scanner input = new Scanner(System.in); String defaultRequest = "Enter a slashed month embedded in any string"; output.println(defaultRequest); String astericksLine = "*********************************************"; output.println(astericksLine); String buffer = input.nextLine(); int slashIndexOne = 0, slashIndexTwo = 0; slashIndexOne = buffer.indexOf("/"); slashIndexTwo = slashIndexOne + buffer.substring( slashIndexOne + 1, buffer.length() - 1).indexOf("/") + 1;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int value = Integer.parseInt(buffer.substring(slashIndexOne + 1, slashIndexTwo)); final int THREE = 3, FOUR = 4, SIX = 6, SEVEN = 7, NINE = 9, TEN = 10, TWELVE = 12; if (value >= 1 && value <= THREE) { output.println("This is the first quarter."); } else if (value >= FOUR && value <= SIX) { output.println("This is the second quarter."); } else if (value >= SEVEN && value <= NINE) { output.println("This is the third quarter."); } else if (value >= TEN && value <= TWELVE) { output.println("This is the fourth quarter."); } } }...
View Full Document

This note was uploaded on 09/16/2011 for the course CSE CSE 1020 taught by Professor Burton,ma during the Fall '10 term at York University.

Ask a homework question - tutors are online