Question

In: Computer Science

Online banking is quick and c Among those people who have an online% approximation to a...

Online banking is quick and c Among those people who have an online% approximation to a binomial distribution with continuity correction.

This program computes and prints the current season of the year
depending on the month and day.
*/


import java.util.Scanner;

public class Seasons {
public static void main(String[] args) {

//default value for the variables month, day and season
int month = 0; // month is set to 0
int day = 0; // day is set to 0
String season = null; // season is set to null

// Creates scanner object
Scanner input = new Scanner(System.in);

System.out.print("Enter a month (ex: 12) : ");

// Check to see if the input is a integer for month value
if(input.hasNextInt()){
month = input.nextInt(); v

Solutions

Expert Solution

The code to finding the Season from the month is given below,

Seasons.java

import java.util.Scanner;

public class Seasons {
    public static void main(String[] args) {
        //default value for the variables month, day and season
        int month = 0; // month is set to 0
        int day = 0; // day is set to 0
        String season = null; // season is set to null

        // Creates scanner object
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a month (ex: 12) : ");
        month = sc.nextInt();
        System.out.print("Enter day (ex: 3) : ");
        day = sc.nextInt();
        outer:
        while(true){
            switch (month) {
                case 12:
                case 1:
                case 2:
                    season = "Winter";
                    break outer;
                case 3:
                case 4:
                case 5:
                    season = "Spring";
                    break outer;
                case 6:
                case 7:
                case 8:
                    season = "Summmer";
                    break outer;
                case 9:
                case 10:
                case 11:
                    season = "Autumn";
                    break outer;
                default:
                    System.out.println("Invalid Month number entered. Month should be b/w 1-12.");
                    System.out.print("Enter a month (ex: 12) : ");
                    month = sc.nextInt();
            }
        }

        System.out.println("Season : "+season);
    }
}

If you have any doubt about this or wants any other method to be added then put in the comments section or update the question. Also, do upvote the solution.


Related Solutions

Some of you have taken online classes before, and some have not. Those of you who...
Some of you have taken online classes before, and some have not. Those of you who are online class veterans, what advice can you give to those who are new to online learning? Do you have any tips, tricks or hints? What are the good, the bad and the ugly of online learning?
Among those who take the Graduate Record Examination (GRE), 67 people are randomly selected. This sample...
Among those who take the Graduate Record Examination (GRE), 67 people are randomly selected. This sample group has a mean score of 558 and a standard deviation of 149 on the quantitative portion of the GRE. Find a 99% confidence interval estimate of the population mean.
In Alexland there are 70,000 people employed and 10,000 people who are unemployed. Of those 10,000...
In Alexland there are 70,000 people employed and 10,000 people who are unemployed. Of those 10,000 6,000 are structurally unemployed and 1,000 are frictionally unemployed. This economy would be described as: In a recession In an expansion Operating at full employment Having an economic boom
Financial market is an intermediary between those who have surplus funds and those who are in...
Financial market is an intermediary between those who have surplus funds and those who are in need of funds. Discuss the functions and roles of money market and capital market, and examine how these roles can affect the financial market in Malaysia
Financial market is an intermediary between those who have surplus funds and those who are in...
Financial market is an intermediary between those who have surplus funds and those who are in need of funds. Discuss the functions and roles of money market and capital market, and examine how these roles can affect the financial market in Malaysia
As online banking technology improves, and people become more comfortable with its use, banks are increasingly...
As online banking technology improves, and people become more comfortable with its use, banks are increasingly electing to replace full-service branches with ATM-only locations (in order to reduce costs). Imagine a local bank is considering making this transition. In order to ensure that such a switch would not result in a significant loss of customers, the bank branch hires a company to conduct a study to sample a portion of its customer base and solicit their thoughts on the possibility...
People who eat lots of fruits and vegetables have lower rates of colon cancer than those...
People who eat lots of fruits and vegetables have lower rates of colon cancer than those who eat little of these foods. Fruits and vegetables are rich in "antioxidants" such as vitamins A, C, and E. Will taking antioxidants help prevent colon cancer? A medical experiment studied this question with 864 people who were at risk of colon cancer. The subjects were divided into four groups: daily beta-carotene, daily vitamins C and E, all three vitamins every day, or daily...
Discuss prevention among those groups who are at risk for development of influenza symptoms.
Discuss prevention among those groups who are at risk for development of influenza symptoms.
There is a theory that people who drink caffeine can run longer than those who do...
There is a theory that people who drink caffeine can run longer than those who do not. To test this theory a random sample of seven people who drink caffeine and a random sample of seven people who do not drink caffeine was obtained and their length of time they could run non-stop was measured, in seconds. non caffeine drinkers 359 280 138 227 203 184 231 caffeine drinkers 394 477 439 428 391 488 454 At the 5% significance...
Contrast the characteristics of people who live in individualistic cultures from those who live in collectivistic...
Contrast the characteristics of people who live in individualistic cultures from those who live in collectivistic cultures.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT