The purpose of this assignment is to understand and implement the basic if else ND to understand how to use it for the real life problems. 1 . Write a program that convert pounds to kilogram and to print an error message if the weight entered in pounds is negative. 2. An Auto Insurance Program – Write a program to determine the cost of an automobile insurance premium, based on driver’s age and the number of accidents that the driver has had. The basic insurance charge is $500.
There is a surcharge of $100 if the driver is under 25 and an additional surcharge for accidents: # of accidents Accident Surcharge 2 3 4 5 6 or more 50 125 225 375 575 No insurance 3. Prompt the user for a number and print good if the number is greater than 5, between 8 & 10 or greater than 33. Otherwise, print bad. Use the I operator in your if statement. 4. Write a program that recommends the number of calories a person should eat each day. Calories are units of energy found in all foods. Base your recommendation on the person’s weight and whether the person has an active or sedentary(inactive) lifestyle.
Don’t waste your time!
Order your assignment!
If the person is sedentary, that person’s activity factor is 13. If the person is active, that person’s activity factor is 15. Multiply the activity factor by the person’s weight to get the recommended number of lories. Start your program by: having the user enter their weight, as a floating point number; having the user enter whether they have active or sedentary lifestyle, as a character, ‘A’ for active or ‘S’ sedentary; use selection statement to use the appropriate calculation for the recommended calories for the selected lifestyle; print out your results on the screen. . Write a program which reads a year (integer) from the user and decides whether that year is a leap year. A year is a leap year (and so contains a February 29) if it is divisible by 4. But if the year is also divisible by 100 then it is onto leap ear, unless it is divisible by 400. This means that years such as 1992, 1996 are leap years because they are divisible by 4 and are not affected by the rest of the rule which applies to century years such as 1900 and 2000. Century years are not leap years except where they are a multiple of 400.
Hence, the years 1700, 1800 and 1900 were not leap years and did not contain a February 29. But the year 2000 was a leap year, the first such century leap year since 1600. 6. Write a program that reads a date from the user in numeric form. For example, February 17, 2003 would be entered as the three integers 2, 17, and 2003. Your program just then determine if the date is a “valid” date. Use the following information to determine if the date is valid: January, March, May, July, August, October, and December all have 31 days.
April, June, September, and November all have 30 days. February has 28 days in a non-leap year and 29 days in a leap year. Echo the input and print either “valid date” or “invalid date” as output.