Basic Java Programming
Today you are going to learn about basics in java programming!
I will tell you on how I learned basic java programming and syntax while doing my activity in our subject ITC C202 Data Structures and Algorithm.
Now the first thing you will probably gonna look at will be at the problem on hand. Next thing is that you analyze it and try to find the design that will provide the solution for the given problem.
Given problems
- A department store gives discounts to all its shoes for sale. Prompt the user to input the cash price (the price of the shoes) of a shoe and the percent discount (discount range is from 10% - 50% only) and output the discount and the discounted price. Use the appropriate data type.
- You are tasked to create a program that will simulate a simple calculator. Prompt the user to choose what arithmetic operation (i.e. +, -, *, /, or %) he/she wants to perform, the input values and finally, display the result based on the chosen arithmetic operation.
- Simulate the a Leap Year Calculator with the following description:A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400.Thus years such as 1996, 1992, 1988 and so on are leap years because they are divisible by 4 but not by 100. For century years, the 400 rule is important. Thus, century years 1900, 1800 and 1700 while all still divisible by 4 are also exactly divisible by 100. As they are not further divisible by 400, they are not leap years.
- Using the 3 loop structures (for, while and do-while), write a JAVA program that will prompt the user to continuously input an integer number. The program will stop accepting inputs if the user entered 0 (zero) and will then output the sum of all input numbers. (For this example, display on your document only one 1 screenshot per loop structure).
We are tasks to create basic java programming for the 4 given problems that will satisfy the problem with the required outputs it should produce.
Problem no. 1
Design:
- The program should ask the user of an input for shoe price and discount rate for the shoe that will be in between 0.1 and 0.5 which will be 10% to 50% discount rate depending on the input of the user
- After getting the inputs of the user the program should solve for the discount amount of the shoe and to solve for it you should multiply the shoe price to the discount rate to get the discount amount.
-To get the discounted price you should subtract the discount amount to the shoe price
-Provide the output of the discount amount and the discounted price of the shoe
Screenshot of the Design code in Python:
Source Code in Java:



Comments
Post a Comment