Solve by using Python language
Validation of Invoice Number
The Gocargo carriers are extending their automation to their
accounts wing too, It is difficult to identify the source and
destination of a cargo in an invoice. So given an invoice number,
determine the "from" and "to" for a cargo.
The format of invoice number is as follows:
* from-Country and to-Country are separated by few digits(atleast
1)
* after to-Country there are few digits.
Input Format :
Input consists of a string, which
corresponds to the invoice number of a cargo.
Output Format :
Output is also a string that
corresponds to the source and destination of the cargo.
Print "Invalid Input", if the input
does not follow the specified format of invoice number.
Refer sample output for formatting specifications:
Sample Input 1:
IND1234PAKI345
Sample Output 1:
IND to PAKI
Sample Input 2:
INDPAKI345
Sample Output 2:
Invalid Input
#Python Code:-
# method to check is the string contains digit or
not
def is_int(s):
flag1=True
try:
int(s)
except ValueError:
flag1=False
return flag1
def main():
s=input("Enter the invoice number of a cargo : ")
n=len(s)
str1=''
str2=''
str3=''
str4=''
flag=1
for i in range(0,n):
if is_int(s[i])==True:
break
else:
str1+=s[i]
for j in range(i,n):
if is_int(s[j])==True:
str2+=s[j]
else:
break
for k in range(j,n):
if is_int(s[k])==True:
break
else:
str3+=s[k]
for l in range(k,n):
if is_int(s[l])==True:
str4+=s[l]
else:
flag=1
break
if len(str1)==0 or len(str2)==0 or len(str3)==0 or len(str4)==0 or
flag==0:
print("Invalid Input")
else:
print(str1,"to",str3)
if __name__=="__main__":
main()
Output 2:-
import sys
invoice_number=input()
From=""
To=""
count=0
check=0
for i in range(0,len(invoice_number),1):
if(invoice_number[i]>='A' and invoice_number[i]<='Z'):
From=From+invoice_number[i];
count+=1
else:
break
for j in range(count,len(invoice_number),1):
if(invoice_number[j]>='0' and invoice_number[j]<='9'):
count+=1
check+=1
else:
break
if(count==len(invoice_number)):
print("Invalid Input")
sys.exit()
check=0
for i in range(count,len(invoice_number),1):
if(invoice_number[i]>='A' and invoice_number[i]<='Z'):
To=To+invoice_number[i];
count+=1
else:
break
if(count==len(invoice_number)):
print("Invalid Input")
sys.exit()
for j in range(count,len(invoice_number),1):
if(invoice_number[j]>='0' and invoice_number[j]<='9'):
count+=1
check+=1
else:
break
print(From+" to "+To)
Solve by using Python language Validation of Invoice Number The Gocargo carriers are extending their automation...
The Cargo arrangementThe Gocargo carriers have a pattern of arranging the cargos in the container. Given the length of edge of the container, print the cargo arrangement pattern in the container as shown in the sample IO. The base of the container is always a square.Note: The Cargo are of unit length.Input format : The input is an integer that corresponds to the side length of the container.Output Format: Output is the cargo arrangement pattern inside the container.Please refer to the sample...
The Weight Detection SensorThe Gocargo carriers has planned to automate the filling of cargos in the container. They have installed a weight detection sensor in the conveyor belt where cargos will be taken to the container. The sensor needs to be programmed in a way that it stops the conveyor sending the cargos, when the maximum capacity of the container is reached or exceeded.Please write a code to enable the sensor to automate this task of finding the number of...
Expiry DateAt Transglobal Logistics, a commodity will be accepted for shipment only if it reaches the destination before the expiry date. Find whether a commodity is accepted for shipping, based on the expiry date, departure date of the commodity from the Source port and number of days required to reach the destination port.Input Format:First line is a string that corresponds to the expiry date.Second line is a string that corresponds to the departure date of the commodity from the source...
Instructions In this problem, you will update the declaration for a function called validateSIN (), using the@paran and @re turn COmments and write the appropriate code for the function to check if a given SIN is valid or not You can test to see if a SIN is valid by using the following calculation. (WARNING: While this Is similiar to the ISBN validation calculation, It Is not the same. There are several differences] Remove hyphens so just digits remain ultiply...
Using the above described algorithm, create a program that: (IN PYTHON) 1.Asks the user which type of credit card he/she would like to find the checksum for. 2. Based on the user's choice of credit card, asks the user for the n digits of the credit card. [Get the input as a string; it's easier to work with the string, so don't convert to an integer.] 3. Using the user's input of the n digits, finds the last digit of...
Program Set 2 10 points) Credit card number validation Program Credit card numbers follow certain patterns: It must have between 13 and 16 digits, and the number must start with: 4 for Visa cards 5 for MasterCard credit cards 37 for American Express cards 6 for Discover cards In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or whether a credit card...
Project DescriptionWrite a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".Project SpecificationsInput for this project:the user must enter the number of employees in the company.the user must enter as integers for each employee:the employee number (ID)the number of days that employee missed during the past year.Input Validation:Do not accept a number less than 1 for the number of employees.Do not accept a negative...
23.4 Project 4: Using Pandas for data analysis and practice with
error handling
Python Please!
23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same...
I need help with this assignment in C++,
please!
*** The instructions and programming style details
are crucial for this assignment!
Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...
The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....