SlideShare a Scribd company logo
JavaCode for Sample Projects
                                                   Methods Project

PaintEstimate.java File

importjavax.swing.JOptionPane;
importjava.text.DecimalFormat;

public class PaintEstimate
{
         public static void main(String[] args)
         {
                  String strNumberRooms;
                  intnumberRooms;
                  String strRoomWallsSqFt;
                  doubleroomWallSqFt;
                  doublelaborCostPerHour = 18;
                  String strGallonCost;
                  doublegallonCost;
                  doubletotalSquareFootage = 0 ;
                  doubletotalJobCharge = 0 ;
                  introomNumberCounter = 1;
                  doublenumJobGallons = 0;
                  doubletotalJobHours = 0;
                  doubletotalPaintCharge = 0;
                  doubletotalLaborCharge =0;


Methods Project                                                      Page 1
DecimalFormatdf = new DecimalFormat("0.00");

              strNumberRooms = JOptionPane.showInputDialog("Welcome to the Painting Cost Estimator. Please enter the number of rooms
                    to be painted." );
              numberRooms = Integer.parseInt(strNumberRooms);

              while (roomNumberCounter<= numberRooms)
              {
                      //take string input and convert to double
                      strRoomWallsSqFt = JOptionPane.showInputDialog("Please enter the total wall space in square feet for room #" +
                                   roomNumberCounter );
                      roomWallSqFt = Double.parseDouble (strRoomWallsSqFt);

                      //increment total square footage variable
                      totalSquareFootage = totalSquareFootage + roomWallSqFt;

                      //increment roomNumberCounter
                      roomNumberCounter = roomNumberCounter + 1;

              }

              strGallonCost = JOptionPane.showInputDialog("Please enter the cost per gallon of the paint that you have selcted." );
              gallonCost = Double.parseDouble(strGallonCost);

              numJobGallons = calculateGallons (totalSquareFootage);

              totalJobHours = calculateJobHours (totalSquareFootage);

              totalPaintCharge = calculatePaintCharge (numJobGallons, gallonCost );

              totalLaborCharge = calculateLaborCharge (totalJobHours, laborCostPerHour);

              totalJobCharge = totalPaintCharge + totalLaborCharge;


Methods Project                                                                                                                        Page 2
System.out.println("PAINT COST ESTIMATE");
               System.out.println("JOB SPECIFICATIONS: Number of Rooms: " + numberRooms + "; Total Wall Space: " + totalSquareFootage + "
                      square feet." );
               System.out.println("COST PER GALLON OF PAINT SELECTED: $" + df.format(gallonCost));
               System.out.println("TOTAL PAINT COST FOR JOB: $" + df.format(totalPaintCharge));
               System.out.println ("TOTAL LABOR COSTS based on an estimate of " + df.format(totalJobHours) + " hours of labor at $" +
                      df.format(laborCostPerHour) + " per hour: $" + df.format(totalLaborCharge));
               System.out.println("ESTIMATED TOTAL COST FOR PROJECT: $" + df.format(totalLaborCharge));
               }

       public static double calculateGallons (double sqFootage)
       {
                doublecoveragePerGal = 115;
                doublenumGallons;

               numGallons = sqFootage/coveragePerGal;

               returnnumGallons;
       }

       public static double calculateJobHours (double sqFootage)
       {
                //double hoursPerSqFoot;
                doublenumJobHours;
                //
                //convert given ratio of 8 hours to 115 sq feet to hours per sq foot
                //hoursPerSqFoot = 8/115;
                //apply number of hours per sq foot to total sq footage
                //multiply total sq feet by conversion of hours to sq feet given
                numJobHours = sqFootage * 8/115;
                returnnumJobHours;
       }



Methods Project                                                                                                                    Page 3
public static double calculatePaintCharge (double numGallons, double costPerGallon )
       {
                doublepaintCharge;

              paintCharge = numGallons * costPerGallon;

              returnpaintCharge;
       }

       public static double calculateLaborCharge (double numJobHours, double laborCostPerHour)
       {
       doubletotalLaborCost;

       totalLaborCost = numJobHours * laborCostPerHour;

       returntotalLaborCost;
       }
}




Methods Project                                                                                  Page 4

More Related Content

What's hot

From OCaml To Javascript At Skydeck
From OCaml To Javascript At SkydeckFrom OCaml To Javascript At Skydeck
From OCaml To Javascript At SkydeckJake Donham
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogrammingdudarev
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
Sylvain Hallé
 
Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++
Santiago Sarmiento
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
kinan keshkeh
 
Tools.cpp
Tools.cppTools.cpp
Tools.cpp
Vorname Nachname
 
VLSI Sequential Circuits II
VLSI Sequential Circuits IIVLSI Sequential Circuits II
VLSI Sequential Circuits IIGouthaman V
 
Program to find factorial of a number
Program to find factorial of a numberProgram to find factorial of a number
Program to find factorial of a number
Swarup Boro
 
Static Variable in C++
Static Variable in C++Static Variable in C++
Static Variable in C++Nasir Hamidon
 
Instalación de emu8086
Instalación de emu8086Instalación de emu8086
Instalación de emu8086
Alex Toapanta
 
Sol10
Sol10Sol10
Mpi cheat sheet
Mpi cheat sheetMpi cheat sheet
Mpi cheat sheet
Cristian Chilipirea
 
MFC Prog
MFC ProgMFC Prog
Probability of finding a single qubit in a state
Probability of finding a single qubit in a stateProbability of finding a single qubit in a state
Probability of finding a single qubit in a state
Vijayananda Mohire
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
Chris Ohk
 

What's hot (20)

Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
From OCaml To Javascript At Skydeck
From OCaml To Javascript At SkydeckFrom OCaml To Javascript At Skydeck
From OCaml To Javascript At Skydeck
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
 
Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
Code
CodeCode
Code
 
Script
ScriptScript
Script
 
Tools.cpp
Tools.cppTools.cpp
Tools.cpp
 
VLSI Sequential Circuits II
VLSI Sequential Circuits IIVLSI Sequential Circuits II
VLSI Sequential Circuits II
 
P2
P2P2
P2
 
Program to find factorial of a number
Program to find factorial of a numberProgram to find factorial of a number
Program to find factorial of a number
 
Static Variable in C++
Static Variable in C++Static Variable in C++
Static Variable in C++
 
Instalación de emu8086
Instalación de emu8086Instalación de emu8086
Instalación de emu8086
 
Sol10
Sol10Sol10
Sol10
 
Mpi cheat sheet
Mpi cheat sheetMpi cheat sheet
Mpi cheat sheet
 
MFC Prog
MFC ProgMFC Prog
MFC Prog
 
Probability of finding a single qubit in a state
Probability of finding a single qubit in a stateProbability of finding a single qubit in a state
Probability of finding a single qubit in a state
 
1
11
1
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 

Similar to Java Code for Sample Projects Methods

golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
Guy Komari
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in Golang
Dan Tran
 
You are given a specification for some Java classes as follows.  A.pdf
You are given a specification for some Java classes as follows.  A.pdfYou are given a specification for some Java classes as follows.  A.pdf
You are given a specification for some Java classes as follows.  A.pdf
eyebolloptics
 
COMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdfCOMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdf
fazalenterprises
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimizedWoody Pewitt
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
yap_raiza
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
ssuser454af01
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
amrit47
 
Rcpp11
Rcpp11Rcpp11
Router Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditionsRouter Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditionsMorteza Mahdilar
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
Apache PIG - User Defined Functions
Apache PIG - User Defined FunctionsApache PIG - User Defined Functions
Apache PIG - User Defined Functions
Christoph Bauer
 
7 functions
7  functions7  functions
7 functions
MomenMostafa
 
Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13
Jason Lotito
 
I need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdfI need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdf
amritashinfosalys
 
What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
Christophe Porteneuve
 
Functional C++
Functional C++Functional C++
Functional C++
Kevlin Henney
 
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfProgramming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
ssuser6254411
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
The Software House
 

Similar to Java Code for Sample Projects Methods (20)

golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in Golang
 
You are given a specification for some Java classes as follows.  A.pdf
You are given a specification for some Java classes as follows.  A.pdfYou are given a specification for some Java classes as follows.  A.pdf
You are given a specification for some Java classes as follows.  A.pdf
 
COMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdfCOMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdf
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Router Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditionsRouter Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditions
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Apache PIG - User Defined Functions
Apache PIG - User Defined FunctionsApache PIG - User Defined Functions
Apache PIG - User Defined Functions
 
7 functions
7  functions7  functions
7 functions
 
Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13
 
I need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdfI need help for my next project due next tuesday can you help me in .pdf
I need help for my next project due next tuesday can you help me in .pdf
 
What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
 
Functional C++
Functional C++Functional C++
Functional C++
 
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfProgramming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
 

More from jwjablonski

Amazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and FormsAmazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and Formsjwjablonski
 
Study Skills Project
Study Skills ProjectStudy Skills Project
Study Skills Projectjwjablonski
 
Java Code For Sample Projects I/O
Java Code For Sample Projects I/OJava Code For Sample Projects I/O
Java Code For Sample Projects I/Ojwjablonski
 
Java Code for Sample Projects Loops
Java Code for Sample Projects LoopsJava Code for Sample Projects Loops
Java Code for Sample Projects Loopsjwjablonski
 
Java Code for Sample Projects Inheritance
Java Code for Sample Projects InheritanceJava Code for Sample Projects Inheritance
Java Code for Sample Projects Inheritancejwjablonski
 
VBA Final Project
VBA Final ProjectVBA Final Project
VBA Final Projectjwjablonski
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projectsjwjablonski
 
Animal Shelter Database Presentation
Animal Shelter Database PresentationAnimal Shelter Database Presentation
Animal Shelter Database Presentationjwjablonski
 

More from jwjablonski (11)

Portfolio
PortfolioPortfolio
Portfolio
 
Amazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and FormsAmazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and Forms
 
Study Skills Project
Study Skills ProjectStudy Skills Project
Study Skills Project
 
Java Code For Sample Projects I/O
Java Code For Sample Projects I/OJava Code For Sample Projects I/O
Java Code For Sample Projects I/O
 
Java Code for Sample Projects Loops
Java Code for Sample Projects LoopsJava Code for Sample Projects Loops
Java Code for Sample Projects Loops
 
Java Code for Sample Projects Inheritance
Java Code for Sample Projects InheritanceJava Code for Sample Projects Inheritance
Java Code for Sample Projects Inheritance
 
VBA Final Project
VBA Final ProjectVBA Final Project
VBA Final Project
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projects
 
Animal Shelter Database Presentation
Animal Shelter Database PresentationAnimal Shelter Database Presentation
Animal Shelter Database Presentation
 
Hangman Program
Hangman ProgramHangman Program
Hangman Program
 
Cents Add Up
Cents Add Up Cents Add Up
Cents Add Up
 

Java Code for Sample Projects Methods

  • 1. JavaCode for Sample Projects Methods Project PaintEstimate.java File importjavax.swing.JOptionPane; importjava.text.DecimalFormat; public class PaintEstimate { public static void main(String[] args) { String strNumberRooms; intnumberRooms; String strRoomWallsSqFt; doubleroomWallSqFt; doublelaborCostPerHour = 18; String strGallonCost; doublegallonCost; doubletotalSquareFootage = 0 ; doubletotalJobCharge = 0 ; introomNumberCounter = 1; doublenumJobGallons = 0; doubletotalJobHours = 0; doubletotalPaintCharge = 0; doubletotalLaborCharge =0; Methods Project Page 1
  • 2. DecimalFormatdf = new DecimalFormat("0.00"); strNumberRooms = JOptionPane.showInputDialog("Welcome to the Painting Cost Estimator. Please enter the number of rooms to be painted." ); numberRooms = Integer.parseInt(strNumberRooms); while (roomNumberCounter<= numberRooms) { //take string input and convert to double strRoomWallsSqFt = JOptionPane.showInputDialog("Please enter the total wall space in square feet for room #" + roomNumberCounter ); roomWallSqFt = Double.parseDouble (strRoomWallsSqFt); //increment total square footage variable totalSquareFootage = totalSquareFootage + roomWallSqFt; //increment roomNumberCounter roomNumberCounter = roomNumberCounter + 1; } strGallonCost = JOptionPane.showInputDialog("Please enter the cost per gallon of the paint that you have selcted." ); gallonCost = Double.parseDouble(strGallonCost); numJobGallons = calculateGallons (totalSquareFootage); totalJobHours = calculateJobHours (totalSquareFootage); totalPaintCharge = calculatePaintCharge (numJobGallons, gallonCost ); totalLaborCharge = calculateLaborCharge (totalJobHours, laborCostPerHour); totalJobCharge = totalPaintCharge + totalLaborCharge; Methods Project Page 2
  • 3. System.out.println("PAINT COST ESTIMATE"); System.out.println("JOB SPECIFICATIONS: Number of Rooms: " + numberRooms + "; Total Wall Space: " + totalSquareFootage + " square feet." ); System.out.println("COST PER GALLON OF PAINT SELECTED: $" + df.format(gallonCost)); System.out.println("TOTAL PAINT COST FOR JOB: $" + df.format(totalPaintCharge)); System.out.println ("TOTAL LABOR COSTS based on an estimate of " + df.format(totalJobHours) + " hours of labor at $" + df.format(laborCostPerHour) + " per hour: $" + df.format(totalLaborCharge)); System.out.println("ESTIMATED TOTAL COST FOR PROJECT: $" + df.format(totalLaborCharge)); } public static double calculateGallons (double sqFootage) { doublecoveragePerGal = 115; doublenumGallons; numGallons = sqFootage/coveragePerGal; returnnumGallons; } public static double calculateJobHours (double sqFootage) { //double hoursPerSqFoot; doublenumJobHours; // //convert given ratio of 8 hours to 115 sq feet to hours per sq foot //hoursPerSqFoot = 8/115; //apply number of hours per sq foot to total sq footage //multiply total sq feet by conversion of hours to sq feet given numJobHours = sqFootage * 8/115; returnnumJobHours; } Methods Project Page 3
  • 4. public static double calculatePaintCharge (double numGallons, double costPerGallon ) { doublepaintCharge; paintCharge = numGallons * costPerGallon; returnpaintCharge; } public static double calculateLaborCharge (double numJobHours, double laborCostPerHour) { doubletotalLaborCost; totalLaborCost = numJobHours * laborCostPerHour; returntotalLaborCost; } } Methods Project Page 4