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

Hands-On Assignment For Flow Control Statements

kkkj

Uploaded by

Musiclover Huu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
8 views

Hands-On Assignment For Flow Control Statements

kkkj

Uploaded by

Musiclover Huu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
Hands-on Assignments for Flow Control Statements ‘Complete tne below hands-on assignments betore proceeding with the next Tope 18) Write @ program to check if © given integer number is Positive, Negative, or Zero. B) Given two non-negative int values, print true if they have the sane last digit, guch a2 with 27 ane 57. 1 Statement = C) lastoigit(7, 17) + true lastoigit(e, 17) > false Iestoigit(3, 113) > true > lirite 2 program to check if a given integer nurber is odd or even. statement) lirite o program to check if the program has received comand Line arguments or not. 1 the pragran has not received arguments then print "No Values", else print all the values in a single Line separated by (comma) exanplel) java example 3S oP: No values Statement) exemple?) java Example Mumbai Bengelor= (o/e: runbal ,sangalore [Hints You cen use length property of on array to check its length] Initialize two character vartablas in a program and display the characters in alphabetical order. [xonplel) if the first cherecter is “2° and second cherecter is “e* then the output ae Statement) exenple2) Af the first character Le ‘a! and second character 4 ‘e', then the output should be 3,2 Initialize 2 character variable in 2 progcon end) print “Alghabhet’ 4f the initialized value dz an slghabnet, Statement print “bigit” 4f the initialized value {2 = number, and print ‘"spectal character’, If the initlalized value 1s anything else. lirite a pragean to accept gender ("Hale” or “Fansle”) and age tron comand Line argunents and print the percentage of interest based on the given conditions. If the gender iz ‘Female’ and age dz betieen 1 and 58, the percentage of interest iz 2.28. If the gender is "Fenele’ and oge is between 58 and 100, the percentage of interest is cet Statement If the gender iz “Male” and age iz between 1 and S8, the percentage of interest i 8.48, Xf the gender is ‘Male’ and age is betucen 59 and 100, the percentage of interest is 430.5%. Initielize 9 character vardoble with an alghabhet in 9 program If the character value Is tn lowercase, the output should be displayed In uppercase tn ‘the following format. example) If the character value ts fn uppercase, the output should be displayed in lowercase in ‘the following format. example) pst ofpsA- rite @ progres to receive 9 color code From the user (an Alphabhet). ‘The program should then print the colar nave, Gazed on the colar code given. ‘Swen ‘The following are the color codes and their corresponding color names. ‘Stotoment R->Red, 8->Blue, G->Green, O-DOrange, Y->Yelloa, U-rhnite. If color code provided by the user is not valid then print "Invalid Code™. It statement a a lirite @ program to receive @ nurber end print the corresponding month none. ‘xanplel) crlofava Sample 12 O/P Expected : Decenber exanple2) es Crlojeve Semple o/p expected + Please enter the month in nuners Exenple3) cr\sgove Sample 15 o/p expected + invelid month 40S Write 2 program £2 print nunbers from 1 to 10 in e single rou with one tab specs lirite @ program to print even numbers between 23 and 57. Each number should be " printed in 2 separate row. 2 rite @ progran to check if @ given runber is prine or not. 43. S| UPite = program to print erine muntere betneen 10 and 99. lurize program co pednt the cue of all the digits of = given cunber. 44 Exonglet) wyP:1234 o7Ps10) ‘Switen ‘Statement For Loop For Loop, For Loop, For Loop. For Loop. 8 6 a lirite program to print = in Floyds format (using for and while loop) example) c\zjave Sample O/P: Please enter an integer ounber Exomple2) Ce\>jave Sample 3 ore: lirite 2 program to reverse a given nunber and print Example) a/P: 234 oves4s24 example?) 1/P:1008 o7e:4001 lipite 2 Java progran to find if the given number iz palindrone or not exanple2) C:\pjava Sample 122011 o/P: 110011 is a palindrome exanple2) C:\pjava Sample 1234 O/P: 1234 is not @ palindrome For Loop, While Loop While Loop | oO

You might also like