let a user enter the state abbreviation, the city name, and
their establishment year. Some error checking
and input conversion is required. For instance, 123 is not valid
input for state; ca
is valid input for state, but store it as CA; AB123 is not valid
input for city name;
SanTA moniCA is valid input for city name, but store is as Santa
Monica;
-1987 is not valid input for year; abc is not valid input for year.
You could also
set a range for the establishment year, such as 1500 to 2000. Make
sure your
program does not crash on invalid input.
2. Replace the ListNode structure with a class
#python 3.6
#defining class City
class City:
def __init__(self):
try:
statename =
input("Enter state")
if(len(statename) = 2 and isalpha(statename)):
self.state = statename.upper()
except:
print("State
should be of 2 characters")
try:
cityname =
input("Enter city name")
if(isalpha(cityname)):
self.name = cityname
except:
print("City name
shuld be alphabetic")
try:
year =
print("Enter establishment year")
if(year >
1500 and year < 2000)
self.estYear = year
except:
print("Establishment year should be between 1500 and 2000")4
#Creating an object
city1 = City()
let a user enter the state abbreviation, the city name, and their establishment year. Some error...
C++ please! (1) Prompt the user to enter the name of the input file. The file will contain a text on a single line. Store the text in a string. Output the string. Ex: Enter file name: input1.txt File content: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! (2) Implement a PrintMenu() function,...