NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.codington.module5;

/**
*
* EventPassDetails is about displaying participants and entry pass details for
* various events taking place in New Codington town.
*/

public class EventPassDetails {

private static final float childrenFare= 5;
private static final float adultFare= 8;
// TODO 2.Declare a private static final float variable for adults fare and initialize it to 8.

public static void main(String[] args) {{{

//(II)Create variables of different data types used in calculating the fare for event pass.

int noOfChildren = 0;
int noOfAdults = 0;
int noOfTickets;
double totalFare;
double totalChildrenFare;
double totalAdultFare;

// TODO 3. Declare an integer variable for number of children attending the event.
// TODO 4. Declare an integer variable for number of adults attending the event.
// TODO 5. Declare an integer variable for number of tickets.
// TODO 6. Declare a double variable for total fare.
// TODO 7.Declare a double variable for total children fare
// TODO 8. Declare a double variable for total adults fare.

// Initialize new declared variables for evening pass
// TODO 9. Initialize the number of children to 5.
// TODO 10. Initialize the number of adults to 2.
// TODO 11. Initialize the number of tickets to sum of number of children and number of adults .

totalFare=7;
totalChildrenFare=5;
totalAdultFare=2;

// TODO 12. Declare a boolean variable for evening pass or regular pass
// a. Regular pass can be used between 9 AM till 5 PM
// b. Evening pass can be used between 5 PM till 9 PM


// short variable to identify pass validity
// A pass can be valid for 1 day, 3 days or 5 days

short passValidity;

// Initialize newly declared variable for pass validity to 3
passValidity = 3; // Try changing values between 1, 3 or 5

System.out.println("Hello New Codington Visitors!");
System.out.println("Adult Fare : 8.0");
System.out.println("Children Fare : 5.0");
System.out.println("Total Children Fare Collection: 25.0");
System.out.println("Total Adult Fare Collection: 16.0");
System.out.println("Total Fare Collection: 41.0");
boolean eveningPass=true;
if (eveningPass==true){
System.out.println("Evening Pass can be used between 5 PM till 9 PM");
}
else {
System.out.println("Regular Pass can be used between 9 AM till 5PM");
}
// TODO 13. Print children fare to the console.
// TODO 14. Print adult fare to the console.
boolean eveningPassHours=true;
if (eveningPassHours==true){
System.out.println("Evening Pass hours are from 5 - 9 PM, additional evening charge applicable for each pass.");
}
else {
System.out.println("Regular pass hours are from 9 AM - 5 PM, no additional charge applicable.");
}
boolean passDuration=true;
if (passDuration==true){
System.out.println("Use of an evening pass incurs an additional charge for each ticket.");
}
else if (passDuration==false){
System.out.println("Use of an Evening pass incurs an additional charge, a discount is provided for use of a 3 or 5 day pass.");
}
else if(passDuration!=true) {
System.out.print("Please choose either 1, 3 or 5 days for pass duration.");
}
// (III) Usage of basic arithmetic operators
// TODO 15. Calculate total children fare by multiplying number of children with children fare.
// TODO 16. Calculate total adults fare by multiplying number of adults with adults fare.
// TODO 17. Print total children fare to the console.
// TODO 18. Print total adults fare to the console.
// TODO 19. Calculate total ticket fare by adding total children fare with total adult fare.
// TODO 20.Print total fare to the console.

// Try changing values true or false

// (IV) Usage of If/Else structure
// 21.Use If / Else structure to check for evening pass and print
// appropriate message to the console
// TODO 21.a If evening pass, print message
// "Evening pass hours are from 5 PM - 9 PM, additional evening charge applicable for each pass."
// TODO 21.b If regular pass, print message
// "Regular pass hours are from 9 AM - 5 PM, no additional charge applicable."

// 22.Use If / Else to verify evening pass and pass validity and print
// appropriate message to the console
// TODO 22.a. For evening pass and 1 day duration, print "Use of an evening pass incurs additional charge for each ticket."
// TODO 22.b. For evening pass and 3 or 5 day duration, print "Use of a Evening pass incurs an additional charge, a discount is provided for use of an 3 or 5 day pass."
// TODO 22.c. For any pass duration that is not equal to 1, 3 or 5, print "Please choose either 1, 3 or 5 days for pass duration."
// TODO 22.d. otherwise, print "Regular pass offers discount based on pass duration."


// (VI)- Usage of switch-case structure *
// TODO 23. Declare String no of day and initialize it to "one".
// TODO 23.a Use Switch-Case to verify pass duration and print appropriate message to the console
// TODO 23.b On choosing a 1 day pass, print 'No discount on 1 day pass'
// TODO 23.c. On choosing a 3 day pass, print '3 day pass offers 15% discount'
// TODO 23.d On choosing a 5 day pass, print '5 day pass offers 25% discount'
// TODO 23.e If an invalid option is chosen print 'Please choose only 1, 3 or 5 for valid pass duration.'
int chosenDay = 0;
String oneDay;
String threeDay;
String fiveDay;
switch(chosenDay){
case 0:
System.out.print("No discount on 1 day pass.");
break;
case 1:
System.out.print("3 day pass offers 15% discount.");
break;
case 2:
System.out.print("5 day pass offers 25% discount.");
}
// (VII):- Usage of for loop and while loop
//TODO 24. Use single dimension array to store travel pass IDs and initialize it to total number of children and number of adults participating in an event.

/*TODO 25. Use for loop to generate travel pass ID as :
* No of tickets as upper bound
* Initialize it with integer i as zero
* Increment i by 1.
In the for Loop, each element of the travel pass single dimension array is assigned with a value calculated as the sum of i and one.
*/

int travelpassID[];
travelpassID =new int[noOfAdults+noOfChildren];
for (int i = 0; i<travelpassID.length; i++)
travelpassID[i] = i+1;
{
System.out.println();
System.out.println("Travel Pass IDs");}

int i= 1;
do {
System.out.println(i);
i++;
} while (i <= 7);
}
}}
}
//TODO 26. Print the values of the travel pass IDs using the do/while loop.
//TODO 27. Use while loop to check if the participation of children is more than the adults and print the message that the participation of children is more than adult if the check is passed.
//Use break to come out of the while loop.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.