Write a program which converts all lowercase letter in a sentence to uppercase.

Similar documents
Oct Decision Structures cont d

IST 297D Introduction to Application Programming Chapter 4 Problem Set. Name:

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

INFO Object-Oriented Programming

Nested Loops ***** ***** ***** ***** ***** We know we can print out one line of this square as follows: System.out.

CS141 Programming Assignment #6

Example. Write a program which sums two random integers and lets the user repeatedly enter a new answer until it is correct.

Practice Problems: Static & instance methods

Some Sample AP Computer Science A Questions - Solutions

Final Examination Semester 2 / Year 2011

Example Program. public class ComputeArea {

Midterm Practice Problems - answer key Answers appear in boldface.

Example: Monte Carlo Simulation 1

CS212 Midterm. 1. Read the following code fragments and answer the questions.

Loops. CSE 114, Computer Science 1 Stony Brook University

1. Find the output of following java program. class MainClass { public static void main (String arg[])

CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Java Basic Programming Constructs

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

Week 2 assignment:

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

Tasks for fmri-setting (Tasks of first and second pilot study at the end)

For that purpose, java provides control structures that serve to specify what has to be done by our program, when and under which circumstances.

CS171:Introduction to Computer Science II

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

More on methods and variables. Fundamentals of Computer Science Keith Vertanen

Computer Applications Answer Key Class IX December 2017

Lab1 Solution. Lab2 Solution. MathTrick.java. CoinFlip.java

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

AP COMPUTER SCIENCE A

Section 002 Spring CS 170 Exam 1. Name (print): Instructions:

Methods and Functions

Question 1 [20 points]

Computer Science is...

SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination

ESC101 : Fundamental of Computing

Repetition, Looping. While Loop

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Control Structures: if and while A C S L E C T U R E 4

Midterm Examination (MTA)

Java Classes: Random, Character A C S L E C T U R E 6

Lecture 14. 'for' loops and Arrays

Chapter 7: Iterations

10/30/2010. Introduction to Control Statements. The if and if-else Statements (cont.) Principal forms: JAVA CONTROL STATEMENTS SELECTION STATEMENTS

Decisions in Java IF Statements

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Program Fundamentals

COE 211/COE 212 Computer/Engineering Programming. Welcome to Exam II Thursday December 20, 2012

Conditionals, Loops, and Style

Chapter 4: Control Structures I

Faculty of Science Midterm. COMP-202B - Introduction to Computing I (Winter 2008)

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. Chapter 1 Introduction to Computers, Programs, and Java

St. Edmund Preparatory High School Brooklyn, NY

CS141 Programming Assignment #8

Section 2.2 Your First Program in Java: Printing a Line of Text

Solutions to Sample JAC444 Midterm Test

DATA TYPES AND EXPRESSIONS

Final. Your Name CS Fall 2014 December 13, points total Your Instructor and Section

CMPS 12A - Winter 2002 Final Exam A March 16, Name: ID:

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010

Section 2.2 Your First Program in Java: Printing a Line of Text

1 Short Answer (10 Points Each)

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition

AP CS Unit 3: Control Structures Notes

Loops! Step- by- step. An Example while Loop. Flow of Control: Loops (Savitch, Chapter 4)

Ryerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6

Loops (while and for)

Java Loop Control. Programming languages provide various control structures that allow for more complicated execution paths.

For that purpose, java provides control structures that serve to specify what has to be done by our program, when and under which circumstances.

Accelerating Information Technology Innovation

1 class Lecture4 { 2 3 "Loops" / References 8 [1] Ch. 5 in YDL 9 / Zheng-Liang Lu Java Programming 125 / 207

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

PROGRAM: import java.util.scanner;

H212 Introduction to Software Systems Honors

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ Test 2. Question Max Mark Internal External

CS110 Programming Language I. Lab 6: Multiple branching Mechanisms

Final Exam Practice Questions

CS 106 Introduction to Computer Science I

Building Java Programs. Chapter 2: Primitive Data and Definite Loops

Question: Total Points: Score:

Following is the general form of a typical decision making structure found in most of the programming languages:

COE 212 Engineering Programming. Welcome to Exam II Thursday April 21, Instructors: Dr. Salim Haddad Dr. Joe Tekli Dr. Wissam F.

In this chapter, you will:

Top-Down Program Development

Object Oriented Programming. Java-Lecture 1

COE 212 Engineering Programming. Welcome to Exam II Monday May 13, 2013

ITERATION WEEK 4: EXMAPLES IN CLASS

A sample print out is: is is -11 key entered was: w

I. True/False: (2 points each)

Transcription:

Write a program which converts all lowercase letter in a sentence to uppercase. For Example: 1) Consider a sentence "welcome to Java Programming!" its uppercase conversion is " WELCOME TO JAVA PROGRAMMING!" 2) If user inputs string like "Hello World!" it should print " HELLO WORLD!" public static void main(string[] args) String sentence,u_sentence; System.out.println("please enter your sentence :"); sentence=in.nextline(); u_sentence=sentence.touppercase(); System.out.println("to upper case :" + u_sentence);

Write a program which accepts an Integer which is an Angle and prints the Quadrant number in which it is. For Example: 1) If user input 30 then it should print 1. 2) If user input 197 then it should print 3 public static void main(string[] args) double angle; System.out.println("please enter the angle"); angle=in.nextdouble(); if(angle >=0 && angle <=90) System.out.println("the Quadrant number of this angle is : 1"); else if(angle >90 && angle <=180) System.out.println("the Quadrant number of this angle is : 2"); else if(angle >180 && angle <=270) System.out.println("the Quadrant number of this angle is : 3"); else if(angle >270 && angle <=360) System.out.println("the Quadrant number of this angle is : 4");

Complete the program which takes date in number format and then makes its addition of the digits until the last digit remains single and the print the number as lucky number. for example if the input is 777 then 7+7+7 =21 = 2+1 =3 so the answer is 3. Example: Enter the date(ddmmyy): 131083 Your lucky number is: 7 Example: Enter the date(ddmmyy): 111111 Your lucky number is: 6 public static void main(string[] args) int date,date_num,sum_mod=0,lucky=0,mod; System.out.println("please enter your b-date"); date=in.nextint(); while(date > 0) date_num=date%10; sum_mod=sum_mod+date_num;

date=date/10; System.out.println("sum " + sum_mod); while(sum_mod >0) mod=sum_mod%10; lucky=lucky+mod; sum_mod=sum_mod/10; System.out.println("Your lucky number is: " +lucky);

Write a program which calculates the sum of natural numbers which are divisible by 3 and 5 less than the number given as input. for example: 1. If user input 10 then output will be 23. 2. If user input 20 then output will be 78. public static void main(string[] args) int div_3_5, sum_div_3_5=0; System.out.println("enter div_3_5"); div_3_5 = in.nextint(); for( int d=3; d< div_3_5; d++) if((d % 3 == 0) (d % 5 == 0)) sum_div_3_5=sum_div_3_5+d; System.out.println("sum_div_3_5 " + sum_div_3_5);

Write a program which takes inputs of height and width of rectangle as integer and print the rectangle. Example: 1) If width = 10 and height = 5 then the rectangle is : ********** ********** 2) If width = 15 and height = 10 then the rectangle is : *************** *************** public static void main(string[] args) int width,height ; System.out.println("please enter the width"); width=in.nextint(); System.out.println("please enter the height"); height=in.nextint();

for(int i=0; i<width; i++) System.out.print("*"); System.out.println(); for(int j=0; j<height-2; j++) System.out.print("*"); for(int i=2; i<width; i++) System.out.print(" "); System.out.print("*"); System.out.println(); for(int i=0; i<width; i++) System.out.print("*"); System.out.println();

Write a program which validates whether the given input year is Leap or Not Leap. For Example: 1) if user inputs 2008 then program should print "Leap". 2) if user inputs 2009 then program should print "Not leap". public static void main(string[] args) int year; System.out.println("please enter year to check :"); year = in.nextint(); if(year % 4 ==0) System.out.println("this is leap year");

Write a program which takes input as integer and display the reverse triangle on the basis of input integer. Example: If user gives input 5 then the triangle should be like this: 12345-1234 --123 ---12 ----1 If user gives input 6 then the triangle should be like this: 123456-12345 --1234 ---123 ----12 -----1 public static void main(string[] args) int triangle; System.out.println("please enter number to draw triangle"); triangle= in.nextint(); int i; for (int t=1; t<=triangle ; t++) i=1; for(int v=1; v<=triangle; v++)

if (t>v) System.out.print("_"); else System.out.print(i++); System.out.println();

Write a program which takes two integers N and M and produces last samples of N of the integers from N-1 to N-M. for example: 1) if user inputs N = 10 M = 4 output will be 9 8 7 6 2) if user inputs N = 5 M = 2 output will be 4 3 public static void main(string[] args) int N,M; System.out.println("please enter N"); N=in.nextInt(); System.out.println("please enter N"); M=in.nextInt(); for(int i=n-1; i>=n-m; i--) System.out.println("integers from N-1 to N-M: " + i);

Write a java program takes input as integer and check whether the number is prime or not. Note: If the variable is prime then display "The number is prime." else display "The number is not prime.". public static void main(string[] args) int x; boolean check = true; System.out.println("enter number to check if prime or not"); x=in.nextint(); for (int i=2; i < x; i++) if(x % i == 0) check = false; break; if(check==false) else System.out.println("not prime"); System.out.println("prime");

Write a program which takes input as string and check if it is palindrome or not. If the string and the reverse of string are same then we say string is palindrome. If string is "level" then the output should be: palindrome If string is "helloworld" then the output should be: not a palindrome public static void main(string[] args) String palindrome; System.out.println("please enter string to check if it's palindrome or not"); palindrome = in.next(); boolean check=true; int n = palindrome.length(); int mid= n/2; for (int i =0; i<= n/2; i++) if(palindrome.charat(i)!= palindrome.charat(n -i -1)) check = false; if(check== true) else System.out.println("palindrome"); System.out.println("not palindrome");