Create a program that keeps telling the user a joke. Consecutive jokes cannot be
ID: 3746864 • Letter: C
Question
Create a program that keeps telling the user a joke. Consecutive jokes cannot be the same. The joke must follow a question and answer format. The program must ask the user if they would like to keep going after each joke. And if the user says no the program should say goodbye and terminate. Otherwise, the program should continue on its next joke. The program should be able to tell a minimum of 20 different jokes. The program should be able to accept more than 3 different responses to the initial joke question. It is java.
Explanation / Answer
Here is the code for your question.
I am just including three jokes here you can add your own jokes there with the same syntax.
Please comment below for further queries about the answer or any modifications needed.
Thank you.
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int row, col, i=0, j=0;
char choice;
char jokes[][] = new char[50][1000];
Scanner scan = new Scanner(System.in);
jokes[0][0]={"Today a man knocked on my door and asked for a small donation towards the local swimming pool. I gave him a glass of water."};
jokes[1][0]={"Light travels faster than sound. This is why some people appear bright until you hear them speak."};
jokes[2][0]={"Person 1: Hey Rachyl, do you remember me? Person 2: Wrong number. Person 1: What’s your number then?"};
//.......pease insert your jokes here...........//
loop:
System.out.print("Do you want to hear a joke(Y/N):");
choicehoice= scan.nextLine();
if(choice=="Y"){
System.out.print(jokes[i++][j++]+ " ");
goto loop;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.