Assignment 01 - Introduction to Flowcharts and Java Programming_Spring 2025.docx - Google Docs
Assignment 01 - Introduction to Flowcharts and Java Programming_Spring 2025.docx - Google Docs
Introduction to Flowcharts
and Java Programming
[Submit all the Flowchart Tasks (Task 1 to 9) handwritten to your Lab Instructors before the next
lab. Submit all the Coding Tasks (Task 10 to 20) in the Google Form shared on buX.]
Lab Policy:Lab-Policy-Student-Version-Fall-2024-Onward.pdf
[Must Read Before Starting Lab of CSE110. Also, Submit a Signed Copy to the Lab Faculties.]
FLOWCHART TASKS
1. Design a flowchart to take a number as input, store it in a variable, and print its cube.
2. C reate a flowchart to convert a temperature in Fahrenheit to Celsius. The user should
input the temperature inFahrenheit,andtheflowchartshoulddisplaythecorresponding
temperature in Celsius. The formula to convert Celsius to Fahrenheit is:
C = (F - 32) × 5/9
3. Designaflowcharttotakethreeintegersa,bandhasinput,whereaandbarethelength
oftheparallelsidesofatrapezium,histhedistancebetweentheparallelsides,andprint
the area of the trapezium.
4. Createaflowcharttofindtheaverageofthreenumbers.Theflowchartshouldtakethree
inputs from the user and display their average.
5. Design a flowchart to take an integer consistingof4digitsasinputandprintthelast2
digits of that number.
6. Design a flowchart to takeanintegerconsistingof4digitsasinputandprintthefirst2
digits of that number.
7. Design a flowchart to take three integers a, n,dasinputwhereaisthefirsttermofan
arithmetic sequence, n is the number of termsanddisthecommondifferencebetween
the terms in the sequence, and print the n-th term of the arithmetic sequence.
8. Designaflowcharttotaketwonumbersaandcasinput(lookattheimagebelow),and
printtheareaoftheportioncoloredingreen.Inthefollowingimage,aistheradiusofthe
circle, and c is the length of the sides of the square.
https://www.youtube.com/watch?v=Gss9sL3Q-8s
CODING TASKS
10.Find out which of the following are legal identifiers in Java, and which are not.
Also,explainwhytheinvalidonesareinvalid.Youcantrytodefineeachofthese(items
a to k below) as a variable in the Dr java interaction pane and find out.
The first one is done for you as an Example. If you want to define hungry, you have to try
int hungry;
a) hungry b) 2AB c) 312.2 d) MOBILE e) “Ans” f) $30
g) Yes/No h) student-id i) A+3 j) ‘X’ k) return
13.WriteaJavacodewheregivenanintegerweneedtoprintthelast2digitsofthatnumber.
[Hint: Use the logic you used in one of the tasks in flowchart]
14.WriteaJavaprogramthatgivenanumberininches(youhavetodeclareandinitializeit
yourself) converts it to meters. Note: One inch is 0.0254 meters.
Test Data:
Given a value for inch: 1000
xpected Output:
E
1000 inch is 25.4 meters
15.WriteaJavaprogramdeclaringtwointegervariablesandinitializingthem.Yourtaskisto
swap the values of these two variables. You must complete it using two different
approaches.
a. By Creating a third variable.
b. Without creating any other variables.
16.WriteaJavaprogramtoconvertminutesintoyearsanddays.Forsimplicity,assumeeach
year consists of 365 days.
Test Data:
Given the number of minutes: 3456789
Expected Output:
3456789 minutes is approximately 6 years and 210 days
17.Suppose,youhavethreeintegervariables:a,b,c.Yourfirsttaskistoassignthevalues2,
5,8inthesethreevariables.Next,youneedtocalculateanddisplaythevalueofvariable
d using the following formula:
Write a Java program based on this mentioned scenario that prints the value ofdafter
c alculation.[Answer: 27]
18.Write a Java program that displays the 2 rightmost digits ofyourstudentIDinreverse
order. For example, if your student id is 23221454, you need to print 4, and then 5.
[Hint: Use the logic you used in one of the tasks in flowchart]
19.Assume a Hexagon where each of the sides are of the same length. From the
visualization,wecanseethevaluesofaandbaregiven.YourtaskistowriteaJavacode
to find the area and the circumference of the Hexagon.
20.Design a Java program to calculate Sin and Cos values from a right-angled triangle.
ssume the values of a and b are 4.5 and 9.5
A
respectively. Finally, print the Sin and Cos values
ofangleAandangleB(SinA,CosA,SinB,CosB).
The formulas to calculate these values are given
below.
int: You need the values for all 3 sides to
H
calculate both sin and cos. You are given only a
and b. How would you get the value of c? You’ll
need the help of Math.sqrt().