top of page

Forum Comments

4-1 What is data structure? Is an array just a collection of the same type of variables?
In ACSL Contest Prep
iamrocklee
Feb 17, 2019
2006 1. 4 2. T 2009 1.6 2.D
0
0
7.1 What is a function or method?
In Introduction to Java
iamrocklee
Nov 14, 2018
thats my code
0
7.1 What is a function or method?
In Introduction to Java
iamrocklee
Nov 14, 2018
import java.util.Scanner; class Mario { public static void main(String[] args) { Scanner karl=new Scanner (System.in); double total=0.0; for(int i=1;i<=4;i++){ int locationA = karl.nextInt(); int dayA = karl.nextInt(); String startA = karl.next(); String endA = karl.next(); int locationB =karl.nextInt(); int dayB =karl.nextInt(); String startB = karl.next(); String endB=karl.next(); double hoursA=(convert(endA)-convert(startA))*0.5; double hoursB=(convert(endB)-convert(startB))*0.5; double pay=0.0; double payA=0.0; double payB=0.0; if (locationA>=400 && locationA<=499){ if (dayA==1||dayA==7)payA=hoursA*13.5;} else if (hoursA>overtimeStart(locationA)){ payA=overtimeStart(locationA)*regularR(locationA)+(hoursA-overtimeStart(locationA))*overR(locationA); } else payA=hoursA*regularR(locationA); if (locationB>=400 && locationB<=499){ if (dayB==1||dayB==7)payB=hoursB*13.5;} else if (hoursB>overtimeStart(locationB)){ payB=overtimeStart(locationB)*regularR(locationB)+(hoursB-overtimeStart(locationB))*overR(locationB); } else payB=hoursB*regularR(locationB); pay = payA+payB; System.out.println(pay); } } public static int convert(String ins){ int outint=0; if(ins.equals("A"))outint=10; else if(ins.equals("B"))outint=11; else if(ins.equals("C"))outint=12; else if(ins.equals("D"))outint=13; else if(ins.equals("E"))outint=14; else if(ins.equals("F"))outint=15; else if(ins.equals("G"))outint=16; else if(ins.equals("H"))outint=17; else outint=Integer.parseInt(ins); return outint; } public static double regularR(int location){ double rate=0.0; if(location>=100 && location<=199)rate=10.0; else if(location>=200 && location<=299)rate=7.5; else if(location>=300 && location<=399)rate=9.25; else if(location>=400 && location<=499)rate=6.75; else if(location>=500 && location<=599)rate=8.0; return rate; } public static double overR (int location){ double rate=0.0; if(location>=100 && location<=199)rate=15.0; else if(location>=200 && location<=299)rate=15.0; else if(location>=300 && location<=399)rate=10.50; else if(location>=400 && location<=499)rate=1.0; else if(location>=500 && location<=599)rate=12.0; return rate; } static public int overtimeStart (int location){ int overtimeStart=0; if(location>=100 && location<=199)overtimeStart=5; else if(location>=200 && location<=299)overtimeStart=6; else if(location>=300 && location<=399)overtimeStart=4; else if(location>=400 && location<=499)overtimeStart=0; else if(location>=500 && location<=599)overtimeStart=6; return overtimeStart; } }
0
0
4.3 How to run part of code under certain conditions?
In Introduction to Java

iamrocklee

More actions
bottom of page