IN CONDITIONAL STATEMENT JAVA,
Outcomes:
Create a program solution of the given problem applying Java conditional
statements
Differentiate If, if-else and if-else if-else statements
Use comparison and logical operators to handle conditional statements in java program.
Instruction:
Read and analyze each problem. Provide a JAVA program to satisfy the required
machine functionality.
Import all java utilities using the syntax: Import java.util.*;
Machine Problem:
Create a java program that would compute and display the total mobile services fee
incurred by a customer. Mobile services include text messages, calls in minutes and
mobile data usage in megabytes.
Each customer was given a customer ID that would indicate the type of mobile plan
he/she availed.
PLAN A
- Customer ID ending
with 0. Loyal member
has 5 digits and above
ID number.
- monthly fixed rate of
P500.00
- allows free text
messaging up to 250
messages. Beyond
that, each message is
charged 90 centavos.
- All-net calls up to 60
mins. Exceeding
minutes applies
P5/min.
- P5/MB. Free use of
mobile data up to
80MB.
- 20% discount from
the total charge for
Loyal member.
PLAN B
- Customer ID ending
with 5. Loyal member
has 5 digits and above
ID number.
- monthly fixed rate of
P750.00
- allows free text
messaging of up to 500
messages. Beyond
that, each message is
charged 70 centavos.
- All-net calls up to 120
mins. Exceeding
minutes applies
P5/min.
- P5/MB. Free use of
mobile data up to
100MB.
- 40% discount from the
total charge.
PLAN C
- Customer ID ending
with 2. Loyal member
has 5 digits and above
ID number.
- monthly fixed rate of
P1,200.00
- allows free text
messaging of up to
1,000 messages.
Beyond that, each
message is charged 50
centavos.
- All-net calls up to 240
mins. Exceeding
minutes applies P5/mins
- P5/MB. Free use of
mobile data up to
500MB.
- 60% discount from the
total charge.
INPUT: The first line of the input file will contain a single integer N that represents the
Customer ID number. Next line consists of 3 integer T, C and D, separated by commas
(,). T is the total number of text messages; C is the total number of calls in minutes and D
is the total data usage in MB.
OUTPUT: The total mobile fee of the customer applying all charges given in the
description and discounts if applicable. In addition, the program must also display an
offer to upgrade the plan type for customers who have exceeded their monthly fixed
rate by 200%. Ex. Plan A – total bill of P1,860.00 means the customer exceeded by
P1,360.00 or 272% from his/her monthly fixed rate of P500 (P1,860-500=1,360).
TEST CASE:
CUSTOMER ID: 39480
300 128 100
----------------------------------------------------
TOTAL ID: P 788.00
IN FORM OF JAVA OPERATION:
CREATE A PROGRAM THAT WOULD:
Create a program solution of the given problem using Java Programming.
Use basic system input/output of Java Programming
Apply java arithmetic
Instruction:
Read and analyze each problem. Provide a JAVA program to satisfy the required
machine functionality.
Import all java utilities using the syntax: Import java.util.*;
Machine Problem:
You have 8 circles of equal size and you want to pack them inside a square. You want
to minimize the size of the square. The following figure illustrates the minimum way of
packing 8 circles inside a square:
Given the radius, r, find the area of the minimum square into which 8 circles of that
radius can be packed.
INPUT: A positive real number (between 0.001 and 1000, inclusivein a single line denoting the radius, r.
OUTPUT: For each test case, output the area of the minimum squarewhere 8 circles of radius r can be packed. Print 5 digits after the decimal.
Your output is considered correct if it is within ±0.00001 of the correct output.
TEST CASE #1
INPUT: 0.1
OUTPUT: 0.34383
INSTRUCTIOKS ARE GIVEN BELOW.
KINDLY WRITE A PROGRAM THAT WOULD:
1. Allow user to enter the size and element of an integer array. Display the sum and
average of all the elements.
2. Allow user to enter the size and element of a string array. Then ask the user to
give a string and display whether that string is present in array or not. (Letter case
doesn’t matter)
3. Allow user to enter the size and element of an integer array. Display all evenindexed elements (assume 0 is even)
4. Allow user to enter the size and element of a string array. Display the longest
string found in the array.
5. Allow user to enter the size and element of a string array. Display the shortest
string found in the array.
6. Allow user to enter the size and element of an integer array. Display all oddindexed elements (assume 0 is even) in reverse order.
7. Allow user to enter the size and element of an integer array. Display the sum of
all even-indexed elements and sum of all odd of all even-indexed elements
(assume 0 is even)
8. Allow user to enter the size and element of character array. Display all vowels
followed by all consonants
9. Allow user to enter the size and element of character array. Then ask the user to
give another character. Check if that character is present in the array, if yes,
replace it with symbol “@”.
10. Allow user to enter the size and element of a string array. Display all strings that
starts with a consonant.
One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)
x = ["sun",[17],2,"king",[3,4]] # Statement 1
y = x[0:8] # Statement 2
z = x # Statement 3
w = y # Statement 4
z[0] = 0 # Statement 5
y[0] = y[0][0:3] + 'k' # Statement 6
y[1][1:3] = [5,8] # Statement 7
x[0] = x[0][1:3] # Statement 8
w[4][0] = 1000 # Statement 9
a = (x[4][1] == 4) # Statement 101. A digital filter is described by
y(n) − 2.56y(n − 1) + 2.22y(n − 2) − 0.65y(n − 3) = x(n) + x(n − 3)
where x(n) is the input and y(n) is the output. Assume all zero initial conditions
(a) Generate the input signal x(n), which is a sinusoid of frequency 500 Hz sampled at 6 kHz.
(b) Compute the first four cycles of the output by directly implementing the above difference equation.
Plot the input and output on the same graph.
(c) Implement the above filter by using MATLAB “filter” function. Compare your results with part(b).
Comment on your result.
(d) Plot the impulse response of the filter by using MATLAB “impz” function. Comment on the results.
1. Write a function called isEven() that uses the remainder operator(%) to determine whether an integer is even or not.
Write a program that asks the user for a word and then prints out that word:
Explain when we can use the Greedy algorithms.
What are the major differences between a microprocessor and a microcontroller?