write a program to (assign two number and print it back after interchanging their values) in java
Answers
Answer:
input “Enter your name: ”, name$
input “Enter a pet animal name: ”, pet$
input “Enter a name for the pet: ”, namepet$
input “Enter the pet food: ”, food$
input “Enter your favourite food: ”, myfood$
input “Enter an adjective, beautiful, ugly, short: ”, adj$
input “Enter pet’s favourite activity: ”, petact$
input “Enter name of room where the pet is kept: ”, room$
input “Where do you watch TV in your house: ”, tv$
input “Give an exclamation (Wow, oh no! ): ”, exclaim$
cls
Print “A FUNNY STORY BY” + namepet$
Print exclaim$ + “! You have a cute pet” + namepet$ + “but, ” + name$ + “ is a weird name for a pet. ”
Print “Why does it ” + petact$ + “ in your ” + tv$ + “? Have you not given it enough ” + myfood$ + “ to eat ” + “?”
Print “I am getting bored. Let’s call your friend ” + pet$ + “ also to your place. ”
Print “We can all eat the magic” + food$ + “in your” + room$ + “and after eating we will turn into” + adj$ + “fairies!!”
clg
color yellow
rect 0,0,300,300
# draw the face
color white
circle 150,150,100
# draw the mouth
color black
circle 150,160,70
color white
circle 150,150,70
# put on the eyes
color black
circle 105,110,15
circle 185,110,15
Here is your java program:
public class interchange {
public static void main(String[] args) {
int a = 5, b = 6;
int temp;
temp = a;
a = b;
b = temp;
System.out.println("a: "+ a+" b: "+b);
}
}