subject

In this assignment, you add the input and output statements to a partially completed Java program. When completed, the user should be able to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.Instructions:Notice that variables have been declared for you. Write the simulated housekeeping() method that contains input statements to retrieve a year, a month, and a day from the user. Add statements to the simulated housekeeping() method that convert the String representation of the year, month, and day to ints. Include the output statements in the simulated endOfJob()method. The format of the output is as follows:month/day/year is a valid date. ormonth/day/year is an invalid date. Execute the program entering the following date:month = 5, day = 32, year =2014 Observe the output of this program. Execute the program entering the following date:month = 9, day = 21, year = 2002 Observe the output of this program./*** The java program BadDate. java that prompts* user to enter year, month and day and finds* if the user given date is valid or not* and display on a message dialog box.* *///BadDate. javaimport javax. swing. JOptionPane;public class BadDate{public static void main(String args[]){String yearString;String monthString;String dayString;// Get the year, then the month, then the day yearString=housekeeping("Enter a Year : ");monthString=housekeeping("Enter a Month : ");dayString=housekeeping("Enter a Day : ");//calling detailLoopdetailLoop(yearString, monthString, dayString);}private static void detailLoop(String yearString, String monthString, String dayString) {int year;int month;int day;boolean validDate = true;final int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31;// Convert Strings to integersyear=Integer. parseInt(yearString);month=Integer. parseInt(monthString);day=Integer. parseInt(dayString);// Check to be sure date is validif( year <= MIN_YEAR ) // invalid yearvalidDate = false;else if ( month < MIN_MONTH || month > MAX_MONTH ) // invalid monthvalidDate = false;else if ( day < MIN_DAY || day > MAX_DAY ) // invalid dayvalidDate = false;String result="";// This is the work of the endOfJob() method// Test to see if date is valid and output date and whether it is valid or notif( validDate == true ){result="Date DD/MM/ : "+day+"/"+month+"/"+year+" is valid";JOptionPane. showMessageDialog(null, result, "Result", JOptionPane. INFORMATION_MESSAGE);}else{result=" Date DD/MM/ : "+day+"/"+month+"/"+year+" is in-valid";// Output statementJOptionPane. showMessageDialog(null, result, "Result", JOptionPane. INFORMATION_MESSAGE);}}//Method that takes a string and prompts user to enter inputprivate static String housekeeping(String prompt){String yearString=JOptionPane. showInputDialog(null, prompt); return yearString;} // end of main() method} // end of BadDate class

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:10, sammigrace5820
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
image
Computers and Technology, 23.06.2019 01:40, littlebirdd987
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
image
Computers and Technology, 23.06.2019 19:00, Heyitsbrandi
Now you’re on your own. include a short summary of this section with plots in your lab report. write a matlab script file to do steps (a) through (d) below. include a listing of the script file with your report. 1 the soundsc(xx, fs) function requires two arguments: the first one (xx) contains the vector of data to be played, the second argument (fs) is the sampling rate for playing the samples. in addition, soundsc(xx, fs) does automatic scaling and then calls sound(xx, fs) to actually play the signal. mcclellan, schafer, and yoder, dsp first, 2e, isbn 0-13-065562-7. prentice hall, upper saddle river, nj 07458. c 2015 pearson education, inc. 4 mcclellan, schafer and yoder, signal processing first. prentice hall, upper saddle river, new jersey, 2003. c 2003 prentice hall. (a) generate a time vector (tt) to cover a range of t that will exhibit approximately two cycles of the 4000 hz sinusoids defined in the next part, part (b). use a definition for tt similar to part 2.2(d). if we use t to denote the period of the sinusoids, define the starting time of the vector tt to be equal to t , and the ending time as ct . then the two cycles will include t d 0. finally, make sure that you have at least 25 samples per period of the sinusoidal wave. in other words, when you use the colon operator to define the time vector, make the increment small enough to generate 25 samples per period. (b) generate two 4000 hz sinusoids with arbitrary amplitude and time-shift. x1.t / d a1 cos.2
Answers: 1
image
Computers and Technology, 24.06.2019 05:30, kaylaamberd
Why is hard disk space important to an audio engineer? why are usb ports and firewire ports useful for an audio engineer? explain in 2-3 sentences. (3.0 points) here's a list of different audio software: ableton live apple inc.'s garageband apple inc.'s logic studio digidesign's pro tools propellerhead sofware's reason sony creative software's acid pro steinberg cubase steinberg nuendo choose one of the software programs listed above, and then go to that software program's web site. read about what the software program is used for, and then write 4-5 sentences about what you learned. (10.0 points) which type of software license is the most limiting? why? explain in 2-3 sentences. (3.0 points) when sending a midi channel voice message, how can you control the volume of the sound? explain in 2-3 sentences. (4.0 points)
Answers: 1
You know the right answer?
In this assignment, you add the input and output statements to a partially completed Java program. W...

Questions in other subjects: