0% found this document useful (0 votes)
5 views7 pages

Assignment 06 - String

Lab Assignment 6 for CSE110 at BRAC University includes various Java programming tasks focusing on string manipulation, such as converting case, reversing strings, checking for palindromes, and validating passwords. Students are required to submit home tasks through a Google Form and handwritten tracing tasks to lab instructors. The document outlines specific coding requirements and provides sample inputs and outputs for each task.

Uploaded by

Rupom
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)
5 views7 pages

Assignment 06 - String

Lab Assignment 6 for CSE110 at BRAC University includes various Java programming tasks focusing on string manipulation, such as converting case, reversing strings, checking for palindromes, and validating passwords. Students are required to submit home tasks through a Google Form and handwritten tracing tasks to lab instructors. The document outlines specific coding requirements and provides sample inputs and outputs for each task.

Uploaded by

Rupom
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
Lab Assignment 6 String BRAC UNIVERSITY, NA Inspiring Excellence « CSE110: Programming Language I Lab Tasks Home Tasks Coding 5 5 Tracing 1 1 [You need to submit only the Home Tasks, Submit all the Homework Coding Tasks (Task 1 to 5) in the Google Form shared on buX. Submit all the Homework Tracing Tasks (Task 6) handwritten to your Lab Instructors before the next lab. LAB Tasks (No Need to Submit) 1. Write a Java program that will take a String as input and convert the lowercase letters to the uppercase letters. The program should keep the other characters (i.e. uppercase letters and symbols) unchanged. /You are not allowed to use .toUpperCase() to solve the problem] Sample Input Output JavaProgrammerl23+ JAVAPROGRAMMERI23++ Tam a hungry coder! 1AM A HUNGRY CODER! 2. Write a JAVA program that will take one string input from the user. Then prints the string in reverse. Sample Input Output ABCD DCBA Hello! tolleH 3. Write a Java program to check if a string is palindrome or not. A string is palindrome if the reverse of the string is the same as the original string. [You cannot use any built-in functions other than .equals(), .charAt(), .length()] Given String Output madam true racecar true Abracadabra false 4, Write a Java program that splits a given string on a given split character. The first input is a String and the second input is the character that will be used to split the first String, Sample Input Sample Output tom@gmail har Tove-Java I - love Java @yahoo,bob@gmail tom@ @yahoo pemail Explanation: The second input which is the character ' is used to split the first input string ‘tom@gmail,harry@yahoo, gmail, mary(@gmail’ into four sepa 5. Write a Java program that takes a string as inp mut and reverses the order of words in it. Sample Input Output CSE110 is easy easy is CSEI10 Attention please! please! Attention 6. Trace the following code, create a tracing table and write the outputs. 1_[public class aWTracingOl ( 2 Public static void main(String] args) ( 3 int x= 0, ¥ a String sum = 5 double p; é while (<9) { 7 yx 2s @ while (y 5) 1 16 sum = "2"5 7 } else { Te 19 ? 20 7 2 r 22D Home Tasks 1. Captain Jack and his crew have discovered a treasure chest full of gold coins. However, the chest comes with a mysterious lock. To open it, they need to input a phrase that should contain a combination of characters where vowel count is divisible by 3 and ‘consonant count is divisible by 5. Write a Java program to help Captain Jack determine if the input phrase has the correct number of vowels and consonants to unlock the treasure chest. Note: Vowels and Consonants count has to be greater than 0 for the treasure to open Sample Input Output Yo-hoo-hoo! Blimey! No Plunde Explanation: The input string has five vowels ‘o, o, o. ©, 0” which is not divisible by 3 and the same applies for consonant rules as well where count of consonants is not divisible by 5. Hence the chest cannot be opened, Yo-ho-Ya-ho-hoo! —_| Aagarr! Me Plunder!! Explanation: ‘The input string has six vowel count which is divisible by 3 and the same applies for consonant rules as well where count of consonants is divisible by 5. Hence the chest can be opened aoouii-uii Blimey! No Plunder!! Explanation: Here the vowel count is divisible by 3, but the consonant count being 0 resulted in the chest not being opened. 2. Write a Java program that takes two strings (lowercase) as user input. Your task is to concat the two strings except the common characters present in the strings. Then print the modified string (uppercase). You can assume that each string will only contain unique characters; that means there will be no duplicate characters in a particular strin; Sample Input Output abed AG bdge arose OSEIL rail 3. Write a Java program that takes a sentence as user input and displays the sentence in aLtErNaTiNg CaPs format, Note that, you have to ignore spaces and other punctuations while altering the characters. Also, your new sentence will always start with lowercase letters. Sample Input Output Hello World! hEILo WoRID! Love Java String Problems. Those are easy. | i LoVe JaVa StRiNg PrObLeMs. ThOsE aRe EaSy. 4. Write a Java program that takes a string as input and determines whether the string qualifies as a strong password. A strong password is defined by the following criteria: > The password must be at least & characters long, > The password must contain characters at least one - © Uppercase letters (A-Z) © Lowercase letters (a-z) © Digits (0-9) © Special characters (e.g., !, @ #, $, ete.) Print ‘True’ if the password is strong, and ‘False’ otherwise. You may consider any character excluding the alphabet, digit, and space as speci | characters, Sample Input Output StrongPass123! True Weak123 False 5. Write a Java program that takes a person’s first name and email’s password as user inputs and checks whether that password is valid or not. A password will be considered invalid ifthe person’s name is present anywhere in that password. You can assume that both the name & password will not contain any uppercase characters and the length of the password will always be greater than the length of name. [Note: You are not allowed to use the built-in contains() or substring) method to solve this problem. Sample Input Output dipu Invalid iamdipul23# shajib Valid happy new year 2025 6. Trace the following code, create a tracing table and write the outputs. 1 [public class HWTracing02( 2 public static void main(Stringl] args) { 3 int test = 1; 4 int j= 0, k = 100; 5 while (k > 0){ 6 String s w+ (k= 5) + "Kaa" 7 7 while Gj

You might also like