Question

In: Computer Science

Using Java create an interactive (the user should be able to input the values) Java Application to process your utility bill for at-least 6 months.

Java Programming

Assignment 7.1 (25 points)

Using Java create an interactive (the user should be able to input the values) Java Application to process your utility bill for at-least 6 months. Use Class-Object methodology and use single dimensional arrays in your application. Write detailed comments in your program. You should have a two classes (for example, MontlyBill.java & MontlyBillTest.java). You can also be creative and create your “own problem scenario” and come up with your “solution”.

Assignment 7.2 (25 points)

Use the same program that you have created in 7.1, and use “two dimensional array”. Your program should display several months and several years. You can also be creative and create your “own problem scenario” and come up with your “solution”.

Solutions

Expert Solution

Step 1

Objective: This program would display the monthly bill amount for six months using class in Java. Here, the user inputs the expenditure (unit) and the rate of electricity consumption per unit is provided in the program.

Step 2

public class MonthlyBillClass {

public double billAmt;
public String monthData;
public int yearData;

public MonthlyBillClass(double billAmt, String monthData, int yearData) {
this.billAmt = billAmt;
this.monthData = monthData;
this.yearData= yearData;
}

public void setBillAmount(double billAmt) {
this.billAmt = billAmt;
}

public double getBillAmount() {
return billAmt;
}

public void setMonth(String monthData) {
this.monthData = monthData;
}
  
public String getMonthName() {
return monthData ;
}

public void setYear(int yearData) {
this.yearData= yearData;
}

public int getYear() {
return yearData;
}

public String printData() {
return this.yearData + " " + this.monthData + " " + this.billAmt;
}
}

Step 3

import java.util.Scanner;

public class MonthlyBillDemo{
public static void main(String[] args) {
int row = 6;
Scanner sc = new Scanner(System.in);
MonthlyBill[] monthlyBill = new MonthlyBill[row];
for (int i = 0; i < monthlyBill.length; i++) {
System.out.print("Enter month name : ");
String monthName = sc.next();
System.out.print("Enter year : ");
int year = sc.nextInt();
System.out.print("Enter bill Unit : ");
double billUnit = sc.nextDouble();
monthlyBill[i] = new MonthlyBill(billUnit, monthName,year);
}

System.out.println("\n" + "Utility bill payments ");
for (int i = 0; i < monthlyBill.length; i++) {
System.out.println( monthlyBill[i].printMonthData());
}

}
}

Step 4

Output:


Related Solutions

Java ProgrammingAssignment 4.1Create an interactive (the user should be able to input thevalues)...
Java ProgrammingAssignment 4.1Create an interactive (the user should be able to input the values) Java Application to process your utility bill for at-least 6 months. Use Class-Object methodology and use single dimensional arraysin your application. Write detailed comments in your program. You should have a two classes (for example, MontlyBill.java & MontlyBillTest.java)..Hint: Use the program (GradeBook) in Fig 7.14 & 7.15(GradeBookTest) as a building template.Assignment 4.2Use the same program that you have created in 4.1, and use “two dimensional array”....
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as:...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as: 1. listnode- for data and link, constructors 2. Singlelinkedlist-for method definition 3. linkedlist-for objects -Insert a node at tail/end in a linked list. -and display all the nodes in the list. -Delete a node at a position in the list Note: Add these methods in the same application which we have done in the class. this is what we've done in the class: class...
JAVA Take in a user input. if user input is "Leap Year" your program should run...
JAVA Take in a user input. if user input is "Leap Year" your program should run exercise 1 if user input is "word count" your program should run exercise 2 Both exercises should run in separate methods Exercise 1: write a java method to check whether a year(integer) entered by the user is a leap year or not. Exercise 2: Write a java method to count all words in a string.
Create a Java application that will prompt the user for the first name of 6 friends...
Create a Java application that will prompt the user for the first name of 6 friends in any order and store them in an array. First, output the array unsorted. Next, sort the array of friends and then output the sorted array to the screen. Be sure to clearly label the output. See the example program input and output shown below. It does not have to be exactly as shown in the example, however it gives you an idea of...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
Create a Java application that will exhibit concurrency concepts. Your application should create two threads that will act as counters.
JAVACreate a Java application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0.
Your Java program should perform the following things:Take the input from the user about the...
Your Java program should perform the following things:Take the input from the user about the patient name, weight, birthdate, and height.Calculate Body Mass Index.Display person name and BMI Category.If the BMI Score is less than 18.5, then underweight.If the BMI Score is between 18.5-24.9, then Normal.If the BMI score is between 25 to 29.9, then Overweight.If the BMI score is greater than 29.9, then Obesity.Calculate Insurance Payment Category based on BMI Category.If underweight, then insurance payment category is low.If Normal...
Create any IOS mobile application using swift that can do the following A user should be...
Create any IOS mobile application using swift that can do the following A user should be able to see all uncompleted tasks in a UITableView • A user should be able to create new tasks • A user should be able to edit a task • A user should be able to mark a task as complete • A user should be able to see all completed tasks in a UITableView • A user should be able to close and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT