NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//Name______________________________ Date_____________
import javax.swing.*;
import java.awt.*;
import java.io.*; //the File class
import java.util.*; //the Scanner class
import javax.swing.JOptionPane;
import java.util.Comparator;
public class DisplaySampleYard extends JPanel
{
private JLabel label;
private JTextField box1, box2, box3, box4, box5;
private Yard[] yard;
private int c=0;
private double total=0;
public DisplaySampleYard()
{
setLayout(new GridLayout(5, 2));

add(new JLabel("Last Name:", SwingConstants.RIGHT));
box1 = new JTextField("", 5);
box1.setHorizontalAlignment(SwingConstants.LEFT);
add(box1);

add(new JLabel("First Name:", SwingConstants.RIGHT));
box2 = new JTextField("", 5);
box2.setHorizontalAlignment(SwingConstants.LEFT);
add(box2);

add(new JLabel("Lawn Size:", SwingConstants.RIGHT));
box3 = new JTextField("", 5);
box3.setHorizontalAlignment(SwingConstants.LEFT);
add(box3);

add(new JLabel("total cost:", SwingConstants.RIGHT));
box4 = new JTextField("", 5);
box4.setHorizontalAlignment(SwingConstants.LEFT);
add(box4);

add(new JLabel("Running total:", SwingConstants.RIGHT));
box5 = new JTextField("", 5);
box5.setHorizontalAlignment(SwingConstants.LEFT);
add(box5);
String sr = JOptionPane.showInputDialog(null,"Which file?");
Scanner infile = null;
try{
infile = new Scanner(new File(sr));
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(null,"The file could not be found.");
System.exit(0);
}
yard = new Yard[infile.nextInt()];
for(int x = 0; x<yard.length; x++)
{
String l = infile.next();
String f = infile.next();
int s = infile.nextInt();
if(s<=10000)
yard[x]=new CustomerSmallYard(l,f,s);
else if (s>10000 && s<=20000)
yard[x]=new CustomerMediumYard(l,f,s);
else
yard[x]=new CustomerLargeYard(l,f,s);
}
sort(yard);


}
public void next()
{
if(c<=yard.length-1)
{
double finalTotal=0;
box1.setText(yard[c].getLastName());
box2.setText(yard[c].getFirstName());
box3.setText(""+yard[c].getSize());
box4.setText(""+yard[c].getCost());
total+=yard[c].getCost();
box5.setText(""+total);
}
c++;

}
public static void sort(Yard[] array)
{
int maxPos;
for(int k = 0; k < array.length; k++)
{
maxPos = findMax(array, k);
swap(array, maxPos, k);
}
}
public static int findMax(Yard[] array, int upper) //what does "upper" do???
{
int max = upper;
for(int x = upper; x<array.length; x++)
if(array[x].compareTo(array[max])<1)
max = x;

return max;
}
public static void swap(Yard[] array, int a, int b)//what are "a" and "b" for???
{

Yard temp=array[a];
array[a]=array[b];
array[b]=temp;
/************************/
/* */
/* Your code goes here. */
/* */
/************************/
}


}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.