0% found this document useful (0 votes)
10 views

Assignment 01 - Introduction to Flowcharts and Java Programming_Spring 2025.docx - Google Docs

The document outlines Lab Assignment 01 for CSE110: Programming Language I, which includes 20 tasks worth a total of 200 points. It consists of flowchart tasks (1-9) and coding tasks (10-20) that students must complete and submit according to specified guidelines. Additionally, students are required to read the lab policy and submit a signed copy to lab instructors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Assignment 01 - Introduction to Flowcharts and Java Programming_Spring 2025.docx - Google Docs

The document outlines Lab Assignment 01 for CSE110: Programming Language I, which includes 20 tasks worth a total of 200 points. It consists of flowchart tasks (1-9) and coding tasks (10-20) that students must complete and submit according to specified guidelines. Additionally, students are required to read the lab policy and submit a signed copy to lab instructors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

‭Lab Assignment 01‬

‭Introduction to Flowcharts‬
‭and Java Programming‬

‭CSE110: Programming Language I‬

‭No of Tasks‬ ‭Points to Score‬


‭20‬ ‭200‬

‭[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‬ ‭in‬‭Fahrenheit,‬‭and‬‭the‬‭flowchart‬‭should‬‭display‬‭the‬‭corresponding‬
‭temperature in Celsius. The formula to convert Celsius to Fahrenheit is:‬
‭C = (F - 32) × 5/9‬
‭3.‬ ‭Design‬‭a‬‭flowchart‬‭to‬‭take‬‭three‬‭integers‬‭a,‬‭b‬‭and‬‭h‬‭as‬‭input,‬‭where‬‭a‬‭and‬‭b‬‭are‬‭the‬‭length‬
‭of‬‭the‬‭parallel‬‭sides‬‭of‬‭a‬‭trapezium,‬‭h‬‭is‬‭the‬‭distance‬‭between‬‭the‬‭parallel‬‭sides,‬‭and‬‭print‬
‭the area of the trapezium.‬
‭4.‬ ‭Create‬‭a‬‭flowchart‬‭to‬‭find‬‭the‬‭average‬‭of‬‭three‬‭numbers.‬‭The‬‭flowchart‬‭should‬‭take‬‭three‬
‭inputs from the user and display their average.‬
‭5.‬ ‭Design‬ ‭a‬ ‭flowchart‬ ‭to‬ ‭take‬ ‭an‬ ‭integer‬ ‭consisting‬‭of‬‭4‬‭digits‬‭as‬‭input‬‭and‬‭print‬‭the‬‭last‬‭2‬
‭digits of that number.‬
‭6.‬ ‭Design‬ ‭a‬ ‭flowchart‬ ‭to‬ ‭take‬‭an‬‭integer‬‭consisting‬‭of‬‭4‬‭digits‬‭as‬‭input‬‭and‬‭print‬‭the‬‭first‬‭2‬
‭digits of that number.‬
‭7.‬ ‭Design‬ ‭a‬ ‭flowchart‬ ‭to‬ ‭take‬ ‭three‬ ‭integers‬ ‭a,‬ ‭n,‬‭d‬‭as‬‭input‬‭where‬‭a‬‭is‬‭the‬‭first‬‭term‬‭of‬‭an‬
‭arithmetic‬ ‭sequence,‬ ‭n‬ ‭is‬ ‭the‬ ‭number‬ ‭of‬ ‭terms‬‭and‬‭d‬‭is‬‭the‬‭common‬‭difference‬‭between‬
‭the terms in the sequence, and print the n-th term of the arithmetic sequence.‬
‭8.‬ ‭Design‬‭a‬‭flowchart‬‭to‬‭take‬‭two‬‭numbers‬‭a‬‭and‬‭c‬‭as‬‭input‬‭(look‬‭at‬‭the‬‭image‬‭below),‬‭and‬
‭print‬‭the‬‭area‬‭of‬‭the‬‭portion‬‭colored‬‭in‬‭green.‬‭In‬‭the‬‭following‬‭image,‬‭a‬‭is‬‭the‬‭radius‬‭of‬‭the‬
‭circle, and c is the length of the sides of the square.‬

‭9.‬ D‭ esign‬ ‭a‬ ‭flowchart‬ ‭to‬‭take‬‭a‬‭number‬‭a‬‭as‬‭input‬‭(look‬‭at‬‭the‬‭image‬‭below),‬‭and‬‭print‬‭the‬


‭area of the portion colored in red. In the following image, a is the diameter of the circle.‬
‭For this course, we’ll be using‬‭DrJava‬‭as IDE for‬‭Java Coding:‬
‭Link to JDK and DrJava‬

‭DrJava Installation Guide:‬

‭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,‬‭explain‬‭why‬‭the‬‭invalid‬‭ones‬‭are‬‭invalid.‬‭You‬‭can‬‭try‬‭to‬‭define‬‭each‬‭of‬‭these‬‭(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‬

‭11.‬‭Write the Java code for the following:‬


‭2.1‬ ‭Declare‬ ‭an‬ ‭integer‬ ‭variable.‬ ‭Initialize‬ ‭it‬ ‭with‬ ‭some‬ ‭value‬ ‭of‬ ‭your‬ ‭choice‬ ‭and‬
‭print it to check the value has been stored properly.‬
‭2.2‬ ‭Declare‬‭and‬‭initialize‬‭another‬‭integer‬‭variable.‬‭Add‬‭this‬‭to‬‭the‬‭first‬‭one‬‭and‬‭print‬
‭out the result. Verify that the addition has been done correctly.‬
‭2.3‬ ‭Now print the product and division of the two‬‭integer‬‭numbers.‬
‭2.4‬ ‭Repeat‬‭exercises‬‭2.1,‬‭2.2,‬‭and‬‭2.3‬‭for‬‭variables‬‭of‬‭data‬‭type‬‭double‬‭.‬‭Verify‬‭your‬
‭answers.‬
‭2.5‬ ‭Repeat‬ ‭exercises‬ ‭2.1,‬ ‭2.2,‬ ‭and‬ ‭2.3‬ ‭for‬ ‭one‬ ‭double‬ ‭data‬ ‭type‬ ‭and‬ ‭one‬ ‭integer‬
‭datatype. Verify your answers.‬
‭2.6‬ ‭Repeat‬ ‭exercises‬ ‭2.1‬ ‭and‬ ‭2.2‬ ‭for‬ ‭variables‬ ‭of‬ ‭data‬ ‭type‬ ‭String‬‭.‬ ‭How‬ ‭does‬ ‭the‬
‭addition‬ ‭operator‬ ‭work‬ ‭for‬ ‭Strings?‬ ‭What‬ ‭if‬ ‭the‬ ‭first‬ ‭variable‬ ‭is‬ ‭an‬ ‭integer‬ ‭and‬ ‭the‬
‭second is a String and vice versa?‬

‭12.‬‭Write‬ ‭Java‬ ‭code‬ ‭that‬ ‭calculates‬ ‭and‬ ‭prints‬ ‭the‬‭circumference‬‭and‬‭area‬‭of‬‭a‬‭circle‬‭with‬‭a‬


‭radius of 4 units. [Hint: use Math.PI to get the value of π]‬

‭13.‬‭Write‬‭a‬‭Java‬‭code‬‭where‬‭given‬‭an‬‭integer‬‭we‬‭need‬‭to‬‭print‬‭the‬‭last‬‭2‬‭digits‬‭of‬‭that‬‭number.‬
‭[Hint: Use the logic you used in one of the tasks in flowchart]‬

‭14.‬‭Write‬‭a‬‭Java‬‭program‬‭that‬‭given‬‭a‬‭number‬‭in‬‭inches‬‭(you‬‭have‬‭to‬‭declare‬‭and‬‭initialize‬‭it‬
‭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.‬‭Write‬‭a‬‭Java‬‭program‬‭declaring‬‭two‬‭integer‬‭variables‬‭and‬‭initializing‬‭them.‬‭Your‬‭task‬‭is‬‭to‬
‭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.‬‭Write‬‭a‬‭Java‬‭program‬‭to‬‭convert‬‭minutes‬‭into‬‭years‬‭and‬‭days.‬‭For‬‭simplicity,‬‭assume‬‭each‬
‭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,‬‭you‬‭have‬‭three‬‭integer‬‭variables:‬‭a,‬‭b,‬‭c.‬‭Your‬‭first‬‭task‬‭is‬‭to‬‭assign‬‭the‬‭values‬‭2,‬
‭5,‬‭8‬‭in‬‭these‬‭three‬‭variables.‬‭Next,‬‭you‬‭need‬‭to‬‭calculate‬‭and‬‭display‬‭the‬‭value‬‭of‬‭variable‬
‭d using the following formula:‬

‭Write‬ ‭a‬ ‭Java‬ ‭program‬ ‭based‬ ‭on‬ ‭this‬ ‭mentioned‬ ‭scenario‬ ‭that‬ ‭prints‬ ‭the‬ ‭value‬ ‭of‬‭d‬‭after‬
c‭ alculation.‬‭[Answer: 27]‬

‭18.‬‭Write‬ ‭a‬ ‭Java‬ ‭program‬ ‭that‬ ‭displays‬ ‭the‬ ‭2‬ ‭rightmost‬ ‭digits‬ ‭of‬‭your‬‭student‬‭ID‬‭in‬‭reverse‬
‭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,‬‭we‬‭can‬‭see‬‭the‬‭values‬‭of‬‭a‬‭and‬‭b‬‭are‬‭given.‬‭Your‬‭task‬‭is‬‭to‬‭write‬‭a‬‭Java‬‭code‬
‭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‬
‭of‬‭angle‬‭A‬‭and‬‭angle‬‭B‬‭(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().‬

You might also like