for some reason the program I am trying to make will not run, and I cannot be bothered to find out why today
but here is one class that might help, plus a modifications of your class:
-----
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class CalendarPanel extends JPanel {
public void CalendarPanel(){
JLabel instructions = new JLabel("open the calendar built into your computer and select for days in a square like 4 5 11 12 and add them together" +
"\n Enter sum of all four days ");
JTextField input = new JTextField();
add(input);
TestClass calculations = new TestClass();
calculations.calclulate();
// add metod to get results from calculations object
// and print theese to a graphical object
// for now you could use JLabels
int day = calculations.getDay();
JLabel firstday = new JLabel("Day 1" + day);
add(firstday);
}
}
--------
import java.util.Scanner;
public class TestClass {
//public static void main(String[] args) {
private int day, day2, day3, day4, sum1; // ALWAYS decalre variabeles private when possible
Scanner calendar;
public void TestClass(){
calendar = new Scanner(System.in);
}
public void calclulate(){
// System.out.println("open the calendar built into your computer and select for days in a square like 4 5 11 12 and add them together");
// System.out.println("Enter sum of all four days:");
int sum = calendar.nextInt();
sum1 = sum - 16;
day = sum1 / 4;
// Print to labels or elsewhere
System.out.printf("first day is: ");
System.out.println(day );
day2 = day + 1;
System.out.printf("second day is: ");
System.out.println(day2 );
day3 = day + 7;
System.out.printf("third day is: ");
System.out.println(day3 );
day4 = day + 8;
System.out.printf("forth day is: ");
System.out.println(day4 );
}
public int getDay(){ // Normally "getters" and "setters" are private
return day;
}
}