Concept explainers
Days in Current Month
Write a
Use the following criteria to identify leap years:
1. A year Y is divisible by 100. Then Y is a leap year if and only if it is divisible by 400. For example, 2000 is a leap year but 2100 is not.
2. A year Y is not divisible by 100. Then Y is a leap year if and only if it is divisible by 4. For example, 2008 is a leap year but 2009 is not.
Here is sample run of the program:
Enter month and year: 2 2008[Enter]
29 days
Enter month and year: 0 0[Enter]
The current month, September 2009, has 30 days.
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java How To Program (Early Objects)
Database Concepts (7th Edition)
Starting Out With Visual Basic (7th Edition)
- السبت ۲ أكتوبر المحاولة رقم 1 :2 HW • Write a program that computes the average of 5 students grades which are entered by the user. Write a program that converts pounds into kilograms. The program prompts the user to enter a number in pounds, converts it to kilograms, and displays the result. One pound is 0.454 kilograms. محتوى إضافي؟ يمكنك إضافة نص وملفات تدعم إجاباتك. إضافة محتوی إرسال الحفظ لوقت لاحقarrow_forwardExercise II Write a program that finds the positive integer solutions of the following equation ax³ + bx² + cx' + d = 0. The user enters the values of coefficients a, b, c and d. The program should test each integer starting from -50 to 50, and each time the equation is equal to zero, it prints its value as well as "is a solution". At the end, it displays the total number of positive integers found. Note that if the equation has more than one solution, the plural word “solutions" is used in the output. Sample run 1: Enter the coefficient of a, b, c, d: 1 -8.5 21 -13.5 1 is a solution 3 is a solution The equation has 2 integers as solutions Sample run 2: Enter the coefficient of a, b, c, d: 6 48 103.5 67.5 The equation has no integer solutions Sample run 3: Enter the coefficient of a, b, c, d: 1 -1 -12 0 4 is a solution The equation has 1 integer solutionarrow_forwardProgram by using C # C sharp My student number :1910206534arrow_forward
- i need the answer quicklyarrow_forwardBox Office: A movie theater only keeps a percentage (20%) of the revenue earned from ticket sales. The remainder goes to the movie distributor. Write a program that calculates a theater’s gross and net box office profit for a night. The program should ask for the name of the movie, and how many adult and child tickets were sold. (The price of an adult ticket is $10.00 and a child’s ticket is $6.00.) Input: the name of the movie, number of adult tickets sold, number of child tickets sold Output: as specified below Object: cin, cout, getline, format output Note: 1. Movie names contain spaces 2, the report is aligned. 3. The decimal number is displayed with 2 decimal places.arrow_forward3. Random Symbol Guessing Game Write a program that generates a random symbol and asks the user to guess what the symbol is. If the user's guess has a higher ASCII number than the random symbol, the program should display "Symbol ASCII too high, try again." If the user's guess has a lower ASCII number than the random symbol, the program should display "Symbol's ASCII too low, try again." The program should use a loop that repeats until the user correctly guesses the random symbol.arrow_forward
- The date June 10, 1960, is special because when we write it in the following format, the month times the day equals the year: 6/10/60 Write a program that ask the user to enter a month in numeric format, a day and a two-digit year. The program should then determine whether the month times the day is equal to the year. If so, it should display a message saying the date is Magic. Otherwise, it should display a message saying the date is not Magic. Output should look as shown below. Create test data and place in a file. Name the code file Last Name + First Initial + "-MagicDates.s", for example "SmithJ- MagicDates.s". Name the test data file in a similar manner. Upload the program and test data files to the Dropbox. 6/10/60 is Magic! 6/10/70 is not Magic. 2/11/22 is Magic!arrow_forwardAssignment Write a program that tracks how much steps the user walks in total in a day and reports if the daily target is reached or not. The program will keep reading double values, each representing steps walked during an individual activity within a day (stepsWalked) until either the user enters a negative value or the daily target of 5000 steps is met. If the user enters a negative number, the program should print total steps walked as a double. Otherwise, if the target is exactly reached, the program should simply print "Target is reached", finally if the target is surpassed the program should print the text "Target is surpassed by", followed by the excess amount above the target as a double, and finally printing the text "steps". NOTE: YOU MUST use a repetitive statement in this question. NOTE: Each stepsWalked value will be given as a non-negative value. You do NOT need to check this. Input Output 3000 1300 500 2305.2 Target is surpassed by 2105.2 steps 450 804.18 776.2 -1…arrow_forwardAssignment Write a program that tracks how much steps the user walks in total in a day and reports if the daily target is reached or not. The program will keep reading double values, each representing steps walked during an individual activity within a day (stepsWalked) until either the user enters a negative value or the daily target of 5000 steps is met. If the user enters a negative number, the program should print total steps walked as a double. Otherwise, if the target is exactly reached, the program should simply print "Target is reached", finally if the target is surpassed the program should print the text "Target is surpassed by", followed by the excess amount above the target as a double, and finally printing the text "steps". NOTE: You MUST use a repetitive statement in this question. NOTE: Each stepsWalked value will be given as a non-negative value. You do NOT need to check this. Input Output Answer assignment 3000 1300 500 2305.2 Target is surpassed by 2105.2 steps 450…arrow_forward
- Submit your answer in the comment section. Days of the Week Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week, where 1- Monday. 2- Tuesday and so forth. If the user types in a 6 then "Saturday should be printed on the screen. For help with Input statements see: Input Function • The program should print an error message if the user enters a number that is outside the range of 1 through 7. For help with If statements and conditions see the following pages: If-Eke Statements and Operators • Name the source code file yourName HW4_1.py. • Test and run the program. Capture the output console and save it as an image file named yourName Hw3 output4 1jpg. • Submit the py and the image files through Canvas.arrow_forward17. Math Tutor Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as 247 +129 The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution: 247 +129 376arrow_forwardIn [ ]: # write a program to accept a number from the user, # print "Play basketball" if the number is Less than or equal to 15 # If the number is equal to 10, display "Play football" 4 # otherwise if the number is more than 15, print "Don't play game" 2arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning