Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

//creating arrays public static String[] name = new String[10]; public static int[] age = new int[10]; public static String[] gender = new String[10]; public static String[] clas = new String[10];...

1 answer below »

creating a
ays 
    public static String[] name = new String[10]; 
    public static int[] age = new int[10]; 
    public static String[] gender = new String[10]; 
    public static String[] clas = new String[10]; 
    public static int[] beginner = new int[10]; 
    public static int[] points1 = new int[10]; 
    public static int[] points2 = new int[10]; 
    public static int[] points3 = new int[10]; 
    public static String[] score = new String[10]; 
    public static int[] total = new int[10]; 
     
    public static void main(String[] args) { 
  
        input(); 
        output(); 
    } 
    public static void input() { 
        
creating loop to ask 10 times 
        for (int i = 0; i < 10; i++) { 
            
asking user to enter all details  
            name[i] = getString("Enter Your Name:"); 
            age[i] = getInt("Enter Your age :"); 
            gender[i] = getString("Enter Your gender:"); 
            clas[i] = getString("Enter class:"); 
            
asking user to enter 1 or 2 for yes/no  
            beginner[i] = getInt("Are you a beginner ?: \n1=Yes\n2=No"); 
            points1[i] = getInt("Enter Amount of Points earned in Competition 1: Halloween Ho
ors:"); 
            points2[i] = getInt("Enter Amount of Points earned in Competition 2: Christmas Crackers:"); 
            points3[i] = getInt("Enter Amount of Points earned in Competition 3: Easter Bunnies:"); 
           
adding up total number of points earned 
            total[i] = (points1[i] + points2[i] + points3[i]); 
             
            
using if statements to determine level 
            if (total[i] >= 24) { 
                score[i] = " Pro"; 
            } else if (total[i] >= 16) { 
                score[i] = "n Average"; 
            } else if (total[i] >= 8) { 
                score[i] = " Below Average"; 
            } else { 
                score[i] = " Bad"; 
            } 
            
if statement to determine if extra beginner points are to be awarded 
            if (beginner[i] == 1) { 
                total[i] = total[i] + 6; 
            } else { 
            } 
        } 
    } 
    
show message with all details 
    public static void output() { 
        for (int i = 0; i < 10; i++) { 
            JOptionPane.showMessageDialog(null, "Name: " + name[i] 
                    + "\n" + "Age: " + age[i] 
                    + "\n" + "Gender: " + gender[i] 
                    + "\n" + "Class: " + clas[i] 
                    + "\n" + "Beginner: " + beginner[i] 
                    + "\n" + "You got " + total[i] + " points" 
                    + "\nYou are a" + score[i] + " Gamer"); 
        } 
    } 
    
get string method 
    public static String getString(String userMsg) { 
        String input = JOptionPane.showInputDialog(userMsg); 
        return input; 
    } 
    
get int method 
    public static int getInt(String userMsg) { 
        int num = Integer.parseInt(JOptionPane.showInputDialog(userMsg)); 
        return num; 
    } 
} 

package why.why;
import javax.swing.JOptionPane;
**
*
* @author majak
*
public class WhyWhy {
/**
* @param args the command line arguments
*
public static void main(String[] args) {
int monTicket = 25;
int tueTicket= 30;
int wedTicket = 40;
int thuTicket = 45;
int friTicket = 35;
int satTicket = 30;
int sixDayTicket = 150;

double monTicketFee = 0.07;
double tueTicketFee = 0.05;
double wedTicketFee = 0.03;
double thuTicketFee = 0.035;
double friTicketFee = 0.025;
double satTicketFee = 0.025;
double sixDayTicketFee = 0.04;



int ticketChoice = 0;
int numOfTickets = 0;
int monTickets = 0;
int tusTickets = 0;
int wedTickets = 0;
int thuTickets = 0;
int friTickets = 0;
int satTickets = 0;
int sixDaysTickets = 0;
int totalTicketsSold = 0;

double monProfit = .1;
double tusProfit = .15;
double wedProfit = .20;
double otherProfit = 0.25;
double totalProfit = 0;

double totalMoney = 0;


int i = 0;
for(i=0;i<2;i++){
ticketChoice = Integer.parseInt(JOptionPane.showInputDialog ("Please select your choice: " +
"\n1 for Monday ticket" +
"\n2 for Tuesday ticket 25e" +
"\n3 for Wednsday ticket 30e" +
"\n4 for Thursdya ticket 40e" +
"\n5 for Friday ticket 45" +
"\n6 for Saturday ticket 35 " +
"\nor 7 for six day ticket 150e" +
"\n "));

if(ticketChoice==1){
XXXXXXXXXXnumOfTickets = Integer.parseInt(JOptionPane.showInputDialog ("How many tickets would you like to purchase"));
XXXXXXXXXXdouble cost = numOfTickets*monTicket;
XXXXXXXXXXdouble bookingFee = cost * monTicketFee;
XXXXXXXXXXdouble amountPayable = cost + bookingFee;
XXXXXXXXXXtotalProfit = totalProfit + (cost * tusProfit);
XXXXXXXXXXtotalMoney += amountPayable;
XXXXXXXXXXmonTickets += numOfTickets;
XXXXXXXXXXJOptionPane.showMessageDialog(null, "Thanks for purchasing " + numOfTickets + " Monday tickets" +
"\nPlease pay: " + amountPayable);

}
else if(ticketChoice==2){
XXXXXXXXXXnumOfTickets = Integer.parseInt(JOptionPane.showInputDialog ("How many tickets would you like to purchase"));
XXXXXXXXXXdouble cost = numOfTickets*tueTicket;
XXXXXXXXXXdouble bookingFee = cost * tueTicketFee;
XXXXXXXXXXdouble amountPayable = cost + bookingFee;
XXXXXXXXXXtotalProfit = totalProfit + (cost * monProfit);
XXXXXXXXXXtotalMoney += amountPayable;
XXXXXXXXXXtusTickets += numOfTickets;
XXXXXXXXXXJOptionPane.showMessageDialog(null, "Thanks for purchasing " + numOfTickets + " Tuesday tickets" +
"\nPlease pay: " + amountPayable);

}
else if(ticketChoice==3){
XXXXXXXXXXnumOfTickets = Integer.parseInt(JOptionPane.showInputDialog ("How many tickets would you like to purchase"));
XXXXXXXXXXdouble cost = numOfTickets*wedTicket;
XXXXXXXXXXdouble bookingFee = cost * wedTicketFee;
XXXXXXXXXXdouble amountPayable = cost + bookingFee;
XXXXXXXXXXtotalProfit = totalProfit + (cost * wedProfit);
XXXXXXXXXXwedTickets += numOfTickets;
XXXXXXXXXXtotalMoney += amountPayable;
XXXXXXXXXXJOptionPane.showMessageDialog(null, "Thanks for purchasing " + numOfTickets + " Wednesday tickets" +
"\nPlease pay: " + amountPayable);
}
XXXXXXXXXXelse if(ticketChoice==4){
XXXXXXXXXXnumOfTickets = Integer.parseInt(JOptionPane.showInputDialog ("How many tickets would you like to purchase"));
XXXXXXXXXXdouble cost = numOfTickets*thuTicket;
XXXXXXXXXXdouble bookingFee = cost * thuTicketFee;
XXXXXXXXXXdouble amountPayable = cost + bookingFee;
XXXXXXXXXXtotalProfit = totalProfit + (cost * otherProfit);
XXXXXXXXXXthuTickets += numOfTickets;
XXXXXXXXXXtotalMoney += amountPayable;
XXXXXXXXXXJOptionPane.showMessageDialog(null, "Thanks for purchasing " + numOfTickets + " Thursday tickets" +
"\nPlease pay: " + amountPayable);
}
else if(ticketChoice==5){
XXXXXXXXXXnumOfTickets = Integer.parseInt(JOptionPane.showInputDialog ("How many tickets would you like to purchase"));
XXXXXXXXXXdouble cost = numOfTickets*friTicket;
XXXXXXXXXXdouble bookingFee = cost * friTicketFee;
XXXXXXXXXXdouble amountPayable = cost + bookingFee;
XXXXXXXXXXtotalProfit = totalProfit + (cost * otherProfit);
XXXXXXXXXXfriTickets += numOfTickets;
XXXXXXXXXXJOptionPane.showMessageDialog(null, "Thanks for purchasing " + numOfTickets + " Friday tickets" +
"\nPlease pay: " + amountPayable);
}
else if(ticketChoice==6){
XXXXXXXXXXnumOfTickets = Integer.parseInt(JOptionPane.showInputDialog ("How many tickets would you like to purchase"));
XXXXXXXXXXdouble cost = numOfTickets*satTicket;
XXXXXXXXXXdouble bookingFee = cost * satTicketFee;
XXXXXXXXXXdouble amountPayable = cost + bookingFee;
XXXXXXXXXXtotalProfit = totalProfit + (cost * otherProfit);
XXXXXXXXXXsatTickets += numOfTickets;
XXXXXXXXXXtotalMoney += amountPayable;
XXXXXXXXXXJOptionPane.showMessageDialog(null, "Thanks for purchasing " + numOfTickets + " Saturday tickets" +
"\nPlease pay: " + amountPayable);

}
else if(ticketChoice==7){
XXXXXXXXXXnumOfTickets = Integer.parseInt(JOptionPane.showInputDialog ("How many tickets would you like to purchase"));
XXXXXXXXXXdouble cost = numOfTickets*sixDayTicket;
XXXXXXXXXXdouble bookingFee = cost * sixDayTicketFee;
XXXXXXXXXXdouble amountPayable = cost + bookingFee;
XXXXXXXXXXtotalProfit = totalProfit + (cost * otherProfit);
XXXXXXXXXXsixDaysTickets += numOfTickets;
XXXXXXXXXXtotalMoney += amountPayable;
XXXXXXXXXXJOptionPane.showMessageDialog(null
Answered 1 days After Jan 31, 2022

Solution

Neha answered on Feb 01 2022
117 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here