Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can i write this in less code in Java? It seems like a mouth full when reading. String babyName= Your baby name is: ; if

Can i write this in less code in Java? It seems like a mouth full when reading.

String babyName= "Your baby name is: ";

if (n == 1) { System.out.print(babyName + "Maddie"); } else if (n == 2) { System.out.print(babyName + "Beth"); } else if (n == 3) { System.out.print(babyName + "Jane"); } else if (n == 4) { System.out.print(babyName + "Anne"); } else { System.out.print(result + "Danny"); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions