Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java, Using the program below program, create a two dimensional array. The program should display several months and several years. import java.util.Scanner; public class
In Java,
Using the program below program, create a two dimensional array. The
program should display several months and several years.
import java.util.Scanner; public class MonthlyBill { public static void main(String[] args) { String arr[]= { "Jan", "Feb", "Mar", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" }; Scanner sc = new Scanner(System.in); System.out.print("What year would you like to enter your bill amount for: "); String year = sc.next(); System.out.print("What month would you like to enter your bill amount for: "); String start = sc.next(); int startIndex = getIndex(start,arr); double bills []=new double[12]; for(int i=startIndex;i<12;i++) { System.out.print("Please enter your bill for "+arr[i]+": "); bills[i] = sc.nextDouble(); } System.out.printf("Bill for " + year + " "); for(int i=startIndex;i<12;i++) { System.out.println(arr[i]+": $"+bills[i]); } } private static int getIndex(String start, String[] arr) { for(int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started