# A travel ticket company sells tickets for airlines, tours and other

Content type
User Generated
Rating
Showing Page:
1/3
A travel ticket company sells tickets for airlines, tours and
other travel - related services. Because long ticket
numbers have often been entered incorrectly by agents,
travel tickets has asked u to code a program that will
indicate if a ticket number entry is invalid, The program
should also prompt the agent to check and re-enter the
correct ticket number. ticket numbers are 10 - 12
characters long. Ticket numbers are designed so that if
you drop the last digit of the number, then divide it by 7,
the remainder of the division will be identical to the last
dropped digit. This process is illustrated in the following
example:
Step 1: Ticket Number 123345676625
Step 2:Remove the last digit leaving 12334567662
Step 3: Divide remaining number by 7 12334567662 divide
by 7
Step 4: Remainder of 6 matches the digit dropped from the
ticket
Step 5: Because the last digit matches the remainder of
the division, the ticket number is valid
write a program that does the process decribed above.
by using java
Solution
import java.util.Scanner;
public class TravelTicket {

Showing Page:
2/3
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
String s = sc.next();
String s1 = s;
if (s.length() < 10 || s.length() > 12) {
System.out.println(\"the entered number is invalid pls re
enter\");
s = sc.next();
s1 = s;
}
if (s != null && s.length() > 0) {
s = s.substring(0, s.length() - 1);
}
//System.out.println(s);
long t=Long.parseLong(s);
long t2=Long.parseLong(s1);
System.out.println(t+\" lon int\");
int t1=((int)(t%7))+1; // as long holds one value less than
int
System.out.println(\"remainder \"+t1);
//String s3= Integer.toString(t1);
int t3= (int)(t2%10);
//Character c=new Character((char)t1);
//System.out.println(\"remainder string \"+s3);
// Character c1= new Character(s1.charAt(s1.length()-1));

Showing Page:
3/3

Unformatted Attachment Preview
A travel ticket company sells tickets for airlines, tours and other travel - related services. Because long ticket numbers have often been entered incorrectly by agents, travel tickets has asked u to code a program that will indicate if a ticket number entry is invalid, The program should also prompt the agent to check and re -enter the correct ticket number. ticket numbers are 10 - 12 characters long. Ticket numbers are designed so that if you drop the last digit of the number, then divide it by 7 , the remainder of the division will be identical to the last dropped digit. This process is illustrated in the following example: Step 1: Ticket Number 123345676625 Step 2:Remove the last digit leaving 12334567662 Step 3: Divide remaining number by 7 1233 4567662 divide by 7 Step 4: Remainder of 6 matches the digit dropped from the ticket Step 5: Because the last digit matches the remainder o ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
I was stuck on this subject and a friend recommended Studypool. I'm so glad I checked it out!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4