kindly help me make a java program that will output 6 pets according to their type. It will first ask the user to enter the type of pet."c" or "d". if the user enters "c" , it will ask the user to enter name for the "cat", else will ask the user to enter name for dog. then output first all cats name, then followed by the list of all dogs name.
char ch; int cointforcat=0; String namecat[]=new String[100]; int cointfordog=0; String namedog[]=new String[100]; for(;;){ System.out.print("Please enter 'c' or 'd': "); ch=input.nextLine().charAt(0); if(ch=='c'){ System.out.println("Enter name for cat: "); namecat[cointforcat]=input.nextLine(); cointforcat++; } if(ch=='d'){ System.out.println("Enter name for dog: "); namedog[cointfordog]=input.nextLine(); cointfordog++; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment