A line containing an integer.
35Output
A line containing a string.
OutLOOPS&CONDITIONS: Create a program that takes in two numbers and then calculate the sum of all even numbers in between the two numbers. The program should also calculate the products of all the odd numbers between the provided numbers.
Sample run 1:
Enter two numbers: 2 8
Output:
Even numbers: 2 4 6 8
Odd numbers: 3 5 7
Sum of even numbers = 20
Product of odd numbers = 105
Create a program that gets values as CMD args as follows, a person's name, year of birth and gender. The program then prints a message as follows:[HINT: if the person is male then the program uses Mr otherwise use Ms]
Sample 01:
Java Lab01_Task04 John 1999 M
Output
Good Mr John, you are 21 years old
You have to build 2 classes ExpenseItem, ExpenseLedger Class ExpenseLedger record expenses you make. You record expense by serial number,description,amount. Create a class ExpenseItem with serialnum, description,amount. Provide constructors, toString for this class. Now in ExpenseLedger class create arraylist of ExpenseItem. Provide following methods
void addExpense(description, amount). This method create an expense item and add it to ledger. Int removeSmallExpenses(double amt):This method will find expense items that are smaller or equal to amount amt and remove items from list. Note that multiple items can be smaller than this value and thus each of these should removed. Also this method should return number of items removed. Double totalExpenditure(): This method calculate total expenditure recorded in ledger so far. You can do this by iterating through expenses list and adding all the amounts to find the total expenditure so far. Override toString method so ledger is printed in well formatted way
1. Squares
Looping random numbers and manipulating those values are fun, too! Why don't we try one that returns the square of an inputted number repeatedly until the user inputs 0? Let's do this!
Instructions:
Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.
Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.
Input
Multiple lines containing an integer.
2
6
Output
Multiple lines containing an integer.
4
36
Sale-Receipt: Write a java program that specifies four parallel one dimensional arrays to store the product name, quantity and cost plus ItemTotal. Each array should be capable of holding a number elements provided by user input. Using a for loop input values for length and width arrays. The entries in the area arrays should be the corresponding values for the product, which is to be used to calculate the costs as follows (thus, itemTotat[i] = quantity [i]* cost [i]) after data has been entered display the following receipt as output:
Sample Run1
Enter the number of products: 2
Enter product 1, Qty and Cost: Banana 4 2.65
Enter product 2, Qty and Cost: Coke 1 9.18
Output1:
Product Quantity Cost Total
---------- ----------- ------- --------
Banana 4 2.65 10.60
coke 1 9.18 9.18
Sub-Total 19.78
VAT(15%) 2.97
TOTAL N$ 22.75
Sample run 1:
Enter two numbers: 2 8
Output:
Even numbers: 2 4 6 8
Odd numbers: 3 5 7
Sum of even numbers = 20
Product of odd numbers = 105
Create a program that gets values as CMD args as follows, a person's name, year of birth and gender. The program then prints a message as follows:[HINT: if the person is male then the program uses Mr otherwise use Ms]
Sample 01:
Java Lab01_Task04 John 1999 M
Output
Good Mr John, you are 21 years old
develop a java console application that either overhaul or automate it.
Implement the following java concept in your solution and highlight in your documentation or code where you did it:
1. Class and Object
2. File and Stream
3. Exception Handling
Write java application with the following information:
- Class Name ; Student
- Method1: AddStudent
- Method2: Print Students
- Method 3: totalStudent
- Method 4: Delete Student