Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I fix this? Output is nearly correct; but whitespace differs. See highlig

ID: 3754985 • Letter: H

Question

How do I fix this? Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input LOL Your output Input an abbreviation: laughing out loud Expected output Input an abbreviation: laughing out loud 2: Compare output 0 / 1 Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input IDK Your output Input an abbreviation: I don't know Expected output Input an abbreviation: I don't know 3: Compare output 0 / 1 Output differs. See highlights below. Special character legend Input XYZ Your output Input an abbreviation: Expected output Input an abbreviation: Unknown 4: Compare output 0 / 1 Output differs. See highlights below. Special character legend Input BFF Your output Input an abbreviation: Expected output Input an abbreviation: best friends forever 5: Compare output 0 / 1 Output differs. See highlights below. Special character legend Input IMH Your output Input an abbreviation: I don't know Expected output Input an abbreviation: Unknown 6: Compare output 0 / 1 Output differs. See highlights below. Special character legend Input IMHO Your output Input an abbreviation: I don't know Expected output Input an abbreviation: in my humble opinion 7: Compare output 0 / 1 Output differs. See highlights below. Special character legend Input tmi Your output Input an abbreviation: Expected output Input an abbreviation: Unknown

Explanation / Answer

Hi Sir, I will demonstrate an easy way how to handle this situation, via Java program:-

1. Create a Map<String, String> and in that map store Abbreviation along with full extrended name with spacing format that you want. See code below.

2. Now from main just pass the Abbreviation, you can automatically get the extended full name with correct spacing that you desire. No overhead in spacing while displaying the value so obtained.

import java.util.HashMap;

import java.util.Map;

public class Abbreviation {

private static Map<String, String> abbreviationMap = new HashMap<String, String>();

static{

abbreviationMap.put("LOL", "Laugh out Loud");

abbreviationMap.put("BFF", "Best Friends Forever");

// keep adding all abbreviations you have in a similiar manner

}

public static void main(String[] args) {

String abbName = "LOL";

String fullName = abbreviationMap.get(abbName);

System.out.println(fullName);

}

}

Please let me know in case of any clarifications required. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote