You are on page 1of 66

# Scribd

Explore

207 full
Uploaded by Varun Bhardwaj on Apr 09, 2017

Related Interests
Array Data Structure
Integer (Computer Science)
String (Computer Science)
Parameter (Computer Programming)
Function (Mathematics)

20
35 views
5/5 score

Document Actions

Other Actions

## SHARE OR EMBED DOCUMENT

Embed
Description: Java Programs practice
View More
Java Programs practice
Flag for inappropriate content

Recommended Documents
Documents Similar To 207 full

HandsOn_3

by Dipak Nandeshwar

by abhishek

by Vinay Pandey

by GuruKPO

by Gordon Duff

(lthomp)

## More From Varun Bhardwaj

Core java

by Varun Bhardwaj

207 full.txt

by Varun Bhardwaj

## Web Scripting (Unit-5)

by Varun Bhardwaj

## You are on page 1of 233

ReverseGiven an
int array and a
number as input,
write a program
elements in the
array greater
than the given
number. Finally
reverse the digits
of theobtained
sum and print
it. Include a class
UserMainCode
with a static
method
? that accepts
2 arguments and
returns an
integer.The first
argument
corresponds to
the integerarray
and the second
argument
corresponds to
the
number. Create a
class Main
which would get
the required
input and call the
static method
present in the
UserMainCode.
Example:Input
Array =
{10,15,20,25,30,
100}Number =
15sum = 20 + 25
+ 30 + 100 =
175output =
571 Input and
Output
Format:The first
line of the input
consists of an
integer that
corresponds to
the number of
elements in the
array.The next n
lines of the input
consists of
integers that
correspond to the
elements in the
array.The last
line of the input
consists of an
integer that
corresponds to
the
number. Output
consists of a
single
integer. Sample
Input610152025
3010015 Sample
and
Reverse*******
*************
*************
*************
**********
571public class
Main {public
static void
main(String[]
args) {int[]
a={10,15,20,25,
30,100};int
b=15;int
i,sum=0,r=0;for(i
=0;i<a.length;i+
+){if(a[i]>b){su
m=sum+a[i];}}//
System.out.printl
n(sum);while(su
m!=0){r=(r*10)+
(sum%10);
sum=sum/10;}S
ystem.out.println
TimeWrite
a program
String variables
containing
time intervals
in hh:mm:ss
two time
intervals and
return a string in
days:hours:minut
es:seconds
format where
DD is number of
days.Hint:
Maximum value
for hh:mm:ss is
23:59:59Include
a class
UserMainCode
with a static
which accepts
the string values.
The return type
is the
string.Create a
Class Main
which would be
used to accept
the two string
values and
call the static
method present
in
UserMainCode.I
nput and Output
Format:Input
consists of two
string.Output
consists of a
string.Refer
sample output
for formatting
specifications.Sa
mple Input
1:12:45:3013:50:
45Sample
Output
1:1:2:36:15Samp
le Input
2:23:59:5923:59:
59Sample
Output
2:1:23:59:58 2.A
dd
Time*********
*************
*************
*************
********public
class Main
{public static
void
main(String[]
args) throws
IOException,
ParseException {
String
s1="23:59:59";St
ring
s2="23:59:59";Si
mpleDateFormat
sdf=new
SimpleDateForm
at("HH:mm:ss");
sdf.setTimeZone
(TimeZone.getTi
meZone("UTC")
);sdf.setTimeZon
e(TimeZone.get
TimeZone("s1"))
;sdf.setTimeZon
e(TimeZone.get
TimeZone("s2"))
;Date
d1=sdf.parse(s1);
Date
d2=sdf.parse(s2);
long
)+d2.getTime();S
tring
);Calendar
cal=Calendar.get
Instance();cal.set
Time(sdf.parse(s
));int
FindDay=cal.get
(Calendar.DAY_
OF_MONTH);if
(FindDay>1)Fin
dDay=FindDay-
1;String
op=FindDay+":"
+s;
System.out.printl
ent SwapsWrite
a Program that
accepts a string
as a parameter
and returns the
string with each
letters reversed.
If the string has
an odd number
of letters, the last
letter is
unchanged.Inclu
de a class
UserMainCode
with a static
method
swapPairs which
accepts a string.
The return type
is string which is
reversed pair of
letters.Create a
Class Main
which would be
used to accept
two Input strings
and call the static
method present
in
UserMainCode.I
nput and Output
Format:Input
consists of a
string with
maximum size of
100
characters.Outpu
t consists of a
single
string.Refer
sample output
for formatting
specifications.Sa
mple Input
1:forget Sample
Output
1:ofgrte Sample
Input 2:New
York Sample
Output 2:eN
woYkr *******
*************
*************
*************
***********pu
blic class
Main{public
static void
main(String[]
args) {String
s1="forget";getv
alues(s1);}public
static void
getvalues(String
s1){StringBuffer
sb=new
StringBuffer();
Recommended Documents
Documents Similar To 207 full

HandsOn_3

## Find the Equation

Midterm S2 Solutions

1-s2.0-S1570866706001067-main

Arrays

L22Arrays1

## C Langvage Programs for Practice

questions

Pointer Program

Pointers in C/C++

Pointers Self.rtf

Matlab2016 Sample

## CBSE Class 12 Computer Science Sample Paper-04 (for 2013)

CSC108_MidPM_2014W.pdf

i46debsc

cplusplus

NPAROMA.ASM

## 2015_16 - Lecture for RTS Laboratory 2 (1)

32-Recursive_Select_1pps.pdf

Lesson 4

ASP_C#notes

DS Lab Assignment

FC124

Steganography

(lthomp)

(lthomp)

(skarrah)

(csteinh)

## Compare "Urdhva Tiryakbhyam Multiplier" and "Hierarchical Array of

Array Multiplier"

tmp244D.tmp

(tfarage)

Arrays

(lthomp)

(lthomp)

(tfarage)

Data Structure

Core java

207 full.txt

unit-1-ppt

Press

Our blog

Invite Friends

LEGAL

Terms

Privacy

SUPPORT

Help / FAQ

Accessibility

Purchase help