You are on page 1of 18
Inlay Task 2181203 - 3.1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN 1, Chris and Dolly were discussing about their monthly bi paid in the due time and identified E vere discuss ¢ ly bills to be paid i i i that they are pending in paying the electrical bill and Dolly asks ot the electrical bill detail Her ils. Here tre the details given by Chris for the pa i are cel payment of bill. Generate electricity bill based on numbers of Class Dias Program: if units are <50 then rate per unit is 2RS. ‘Units are >= 51 and <= 100 then rate per unit is 3RS. units are>= 101 and <= 300 th it i bill. yen rate per unit is 5 Rs and add extra, 100Rs to the total units are >=301 and <= 450 itis 1 am then rate per unit is 6RS and add extra 200 RS to the total units are >450 then per unit is 8RS and add e: then per un xtra 250 RS to the total bil Now your task is to identify the units utilized and the amount to be ‘0 gram: nein Gongs t: ein GaN I | Package vscekss Impor t Jovaubil. ; Public Class Pang Public Stah'e vord main ( Shing C7 args ) System.out- print ("Enter number of Units Consumed” 2 Scanner Stan> new Scanner (System ir D5 {nt nedean. neat Ent) Sean. closeld; int bin ig Cn £0) bills n* 2) elte if (moze BE NE>100) bin=n*3; 2151203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN ele tf (m>ztor £4 ne=300) bins (n45) 410; elte if (m>=301 && Ne= USO) bit = Cn%e) 42005 else bre (na 42905 System out printly ("Total Gilt: "+ bu): 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN 2 Balanced strings are those that have an equal i : ngs ¢ quantity of 'L' and 'R’ r string s, split it into some number of substrings such that wach ssbating Talanced meant . Return the maximum number of balanced strings you can obtain. LINK: bit.ly/CTOOD-W1PO1 Class Diagram: sginlogtins pwveids Program: ackoge etoods {mport govonuti). 5 Public cla Rat Public Static Void train CSringf Jarqs ) Scorer ( Systenin)5 © Scanner San = Ne Sieg, $2 Sanneet Os Scan-close Os far Cao, 10,1205 for (ict T23 {¢5:Lorgth © yieed Lore (gcharnt@ sstly dary ele tty HU (fee) tices reo, deo z 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN Syglemoud- print Coy 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN 3.integer type to use if one wants to store a positive integer n? Link: hitps://bit.ly/CTOOD-W1P3 * Class Dingram: Program: Package etood> Aiport Sava l *> Public class TH6{ Public Stabe oid proin (Stieg 1 args ) YL Starner Scant neo Stonner (Systeenin) § Jong vn) rey L ns S@ament Longl ss ae (nz eBybe. er NEALE) Syslern.out print (wbyte" 5 ele tt (ae = Short MAF NALVE? Syslern-out. prints ("hoe"); 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN alee if Cree Toteger , MAx-\ALOE J © Syglecrout: Pintle (ens elie, Sytkemout. pictle ("Jong") y Catch ( Excphon © ) Lg ulemn out Prick be ("Big tateger J 4 . ra 1 1203 - COMPUTATIONAL THINENS a ee ESIGN oN 21s¢! Post-lab Task: 1. The Fibonacei numbers, commonly denoted F(n) forma sequence, called the pi such that each number is the sum > rthe two preceding ones, starting from wn ng =0,F (1)=1 F(n) =F (n= 1) +F(n-2) forn> 1. Given n, calculate F(n), Ny, and | Ty, ers up to n number. . Now oa Magi i the Fibonacei series num! Class Diagram: apanea! ry ‘JiNed Program: Package week import Jauasutil.*2 Publt clo Paldd Public Stable oid main tat fiso, TREE AS (Shieg ls ovas) ¢ (renter a number") Sutter. out. Riot Scanner Ston = Te Stanner (Sustem: in\5 tat THs Son met Int» Ston.clote t) Hy lint tos tears fee) ¢ System,out- piotln (110. Aye dreds '21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN 2, Given a number N, check if'a number is perfect or not. A number is sai ‘ : ' erie : alls factors excluding the number itself is equal to the number. Ty Tae Eee ot whether the given number.is Perfect number or not Seen Class Diagram: Program: Facloge ctood) feaport Sava.edtl. 25 Pub\e lors Pad! e Public Static Usid train (Sting Clarqe L Sugleen-out. print (Enter acnumbers "Is Scanner, Stans news Stormer (Susten'to 3 Set on = Som, nextInt Oy Stan, chore Os fat Sumsos ff 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED Desigy IGN 14 (Sue =s0) Syskemoukprintly ('VEC" y else, Syskem.out. pitts (0: : 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN ‘Skill Session: 1. Forevery x, try x” where y starts from 2 and i “ s increases one by one until ei shan nn Waite 8 program to find power of a number using while ae Ths eee ea Cp is taken from the test cases. Now your task to is to find paverce etn as m er. (Hint: Use while Loop). Class Diagram: steno (20910)! Shig J: void Program: Fac hage ctoods Zenport Jovautl *5 pubk clos Paes { : public Stabe Mod cred (Shieg Caged < Scanrer Stans Tew Scanner (Sugttesn nds Syuternout: pricit lo (Se Eotce lales 7, fet bares San rent Tl? 5 Systeen, out piot(n (" Eoter exporent $"')5 vot ant Stan. next Pat ld) Dovey ange is ~tphile (nd) Lanes basetants a a Syutem, oar. Paint (" Poruer of tte caumber 5 "ton: yal Ta L 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN 4 2. Romeo proposed Juliet, Juliet is the college topper, so she has given a crazy star pat, to print it, If Romeo prints it then there is some chance that Juliet accepts his Proposal for is very poor at coding. can you please help to make their love successful by | Bugp® inti It Printi pattern? ing thee wees eee a * Class Diagram: Program: Yor tage etoods Public clors Paae ¢ Public Gate void wain (Shing aged q Roe Lint isos fee far) Sugkenout pint ll" "); or] oe (int eso KOS-P aH hte) 1 Sypleniout pint ('#; 5 Gustern outs print Cnn") s Bf rr i 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN 3. Ravi likes printing tables. So, whenever he finds a number, he will print a table for it. Given an integer, n, print its first 10 multiples. Each multiple n x i (where 1 <= i <= 10) should be printed on a new line in the form: n x i= result, Link: https://bit.ly/CTOOD-W1S3 Class Diagram: sepainGrait dt Shing yuo Program: Poekage ctood» Yenport fou aks Public closs Paar Public Stabe urid (ode, Sronner. tan eres Starner (Seatterosin > 4 OLY my , en Syste out, prot (“Enter a csumbe Sconrne wtIntd)! (Shing (J orgs 4 int os Stan, close 0! Uae vases Oe) Lo gugvemoots pic: (62 Tate's ¥ 203 - COMPUTA 218C1i 4, ‘The Utopian Tree goes through 2c¥¢1es of oto ring wil a it double, i ii it | meter. ei} summen its height increases bY ian row cycles? sacl a at the onset of spring, How tall will the tree bea yy v Link:https Jy/(CTOOD-W1 -S4 Class Dingram: Program: Package Ctood) Jenport fouautl ?) Public clou Pgté d Pulse Gatic Noid MO (sting CA args) f Scanner Scan = need Scanner (Rarternsind 5 ‘wt ne StanmextIntl yy Ston. chose(s’ Yat height) eet Cink’ J Jean site) ‘A Cid Lee0) Kelgnt 445 4 dre . height 2 2+ ho ke 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN Syslem.out print Creve nts y angel | 2151203 - COMPUTATIONAL 11 SRE: 2 binary (base-2). Then find and Print 5. Given a base-10 integer, n, convert it t : 1 ntive 1's in n’s binary representation tt b iy ion, Whee tg denoting the maximum number of consce different bases, itis common to show the base as a subscript. welt Example: : hy, The binary representation of 125 is 1111101. In base 10, there are 5 and 1 e¢ng two groups. Print the maximum, 5. CCUtiye. me i LINK: ht /CTOOD-W1-S5 Class Diagram: Program: Package ctood® Jenport tava. uk s public class Pgae a Stabe int nS Kit i Seen Sobe wot punber OF Conseeatin Cint ny ublic ‘ ; 4 Jot arrayl Y= Dee int (60) 5 Jot 1205 toile (1b=> 5 L owayf?ds 2S meales fay 5 Yat Count 20+ -fos Cint qeters decoy de L 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN | if (oway C1220) A Count +t y else : break’, I | teh Courts (Shing CYarq: » 3 ; abe Stic yord Cain (Sqptemsinds g apenas Sommer L &loemer SOF ms Sloan mpentTotlss SCon. closet >’, Saile da pink enurebucOt Gnsecertue (ary item souk Pie y .¢1203 - COMPUTATIONAL THINKING FOR OBJECT ONENTED DESIGN “ 215 e x containing n digits. Ifsum of each digit raised to power n ig ual t sa A i.e. Now your task to cl © the itself then the number is said to be Armstrong number i.e. Now your heck whe hy number is Armstrong number or not. S My Class Diagram: ‘teleclete tang Cain Boles a 1 Bain AT Tig)! Nien Program: Package Ctood> Tmpoit fava; Public Chas Paso Public Sate tot ans Public Static eoltan checrtmetong (set n) Link. tesnpsn, Seis 2 tok Power = Git > Nath, (og vo nd 1% cohile (nso) ‘ \ot re achtos Sums Sunt (int > Mon ~Por, (, Pocus) - men fp! 7 ae (Sum == temp) : tetuin huss y feturn alte: 21SC1203 - COMPUTATIONAL THINKING FOR OBJECT ORIENTED DESIGN Rublic Shah word Male (Shingh) ovgs> 4 Stoner Cons revs Seamer (Saute ind 5 Y A wane Sgakem out psint (Ever o need ens Stan. nerbret ly, Sen, Chose (3% wf Celucer Benttiorg (99 ) Sygtem,. out pint (v verry ebe. : f System, out: pint (NON (For Evaluator’s use only) Comment of the Evaluator (if Any) Evaluators Observation Marks Secured: out of, Full Name of the Evaluator: Signature of the Evaluator Date of Evaluation:

You might also like