An office furniture company sells furniture in three colors: red, black and green. Every item in their inventory system has a 5-character code. The last two characters are always used to represent color. If an item is red, the last two characters are “41”. If an item is black, the last two characters are “25”. If an item is green, the last two characters are “30”. Ask the user to enter a 5-character code. Use the last 2 characters to determine the color. Display the color in the console window (“Red”, “Black” or “Green”). If the inventory code is not exactly 5 characters long, or if the last two characters are neither “41”, “25” nor “30”, display an error message (“Invalid inventory code”). [Hint: Use the substr function to extract the last two characters of the string and see whether the extracted substring is “41”, “25” or “30”).
needhelp919 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.