Results 1 to 3 of 3
  1. #1
    rexter is offline Member
    Join Date
    Mar 2017
    Posts
    2
    Rep Power
    0

    Unhappy HI guys., i wonder about the problem with my code since it wont run but no errors

    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    import java.util.Scanner;




    public class TestClock {


    static Scanner ch = new Scanner(System.in);
    static Scanner vk = new Scanner(System.in);
    static Scanner ta = new Scanner(System.in);
    static Scanner sh = new Scanner(System.in);

    /**
    * @param args the command line arguments
    */

    public static void main(String[] args) {
    Digital aa = new Digital(" "," ");
    Analog wa = new Analog("","");
    Clock cm = new Clock(00,00);
    Clock cl = new Clock(00,00);

    int time;

    do{
    System.out.print("\n\tPress the desired number of choice, then press Enter to continue");
    System.out.print("\n\t[1] to display the Analog Clock\n\t[2] to display the Digital Clock\n\t[3] to exit");
    System.out.print("\n\t ");
    time = ta.nextInt();
    /*In analog clock, there is no possible option for indicating AM&PM*/
    if(time == 1)
    {
    System.out.print("\n\tEnter the information of Analog Clock");
    System.out.print("\n\tEnter the Brand: ");
    String t = sh.next();
    wa.setBrand(t);
    System.out.print("\n\tEnter the color: ");
    String h = sh.next();
    wa.setColor(h);
    System.out.print("\n\tEnter the Number where minute hand pointed:\n\tchoices: 1,2,3,4,5,6,7,8,9,10,11,12 ");
    System.out.print("\n\tEnter the Minute hand value : ");
    cl.setcalc(ch.nextInt());/*This is where analog clock minute hand pointed value to equivalent value,grabs inputted value*/
    wa.Distinct();/*This is where analog clock minute hand pointed value to equivalent value,displays defference between digital clock and the calculated value*/
    wa.Location();
    wa.ClockInfo();
    }
    else if(time == 2)/* SECTION FOR DIGITAL CLOCK*/
    {
    System.out.print("\n\tEnter information of the Digital Clock");
    System.out.print("\n\tEnter the Brand: ");
    String t = sh.next();
    aa.setBrand(t);
    System.out.print("\n\tEnter the color: ");
    String h = sh.next();
    aa.setColor(h);
    System.out.print("\n\tEnter the Time to identify or convert 24 to 12 time format: ");
    System.out.print("\n\tEnter the Time : ");
    cm.setconv(vk.nextInt());/*This is where digital 24hour format value to equivalent 12hour value,grabs inputted value*/
    aa.Distinct();/*This is where digital 24hour format value converted to equivalent 12hour value,displays defference between analog clock and the converted value*/
    aa.Location();
    aa.ClockInfo();
    }

    }while(time !=3);
    }
    }

    ---------------------------------------------------------------------

    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    public class Analog extends Clock {

    public Analog(String a, String n)
    {
    super(a, n);
    }


    public void Distinct()
    {
    System.out.print("\n\tCalculation: pointing numbers to tell time");
    System.out.print("\n\tCalculation: "+getcalc());
    }

    public void Location()
    {
    System.out.print("\n\tLocation: Walls");
    }
    @Override
    public void ClockInfo()
    {
    System.out.print("\n\tMade of Clock: "+getType()+"\n\tClock color: "+getColor());
    }
    }

    ---------------------------------------------------------------------------


    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    public class Clock {
    private int hour,minute,minutes;
    public int bell,Tick;

    private String type, color;
    public Clock(String t, String h)
    {
    type = t;
    color = h;

    }

    private int calculate,convert;
    public Clock(int calc, int conv)
    {
    calculate=calc;
    convert=conv;

    }

    public void setcalc(int minute){

    calculate =minutes ;
    }
    public int getcalc(){
    return minutes;
    }

    public void setconv(int hour){
    convert = Tick;
    }
    public int getconv(){
    return Tick;
    }







    public void setBrand(String t)
    {
    type = t;
    }

    public String getType()
    {
    return type;
    }

    public void setColor(String h)
    {
    color = h;
    }

    public String getColor()
    {
    return color;
    }

    public int convert(int hour){


    if(hour==13&&hour<=24)
    {
    Tick=1;
    }
    else if(hour==14&&hour<=24)
    {
    Tick=2;
    }
    else if(hour==15&&hour<=24)
    {
    Tick=3;
    }
    else if(hour==16&&hour<=24)
    {
    Tick=4;
    }
    else if(hour==17&&hour<=24)
    {
    Tick=5;
    }
    else if(hour==18&&hour<=24)
    {
    Tick=6;
    }
    else if(hour==19&&hour<=24)
    {
    Tick=7;
    }
    else if(hour==20&&hour<=24)
    {
    Tick=8;
    }
    else if(hour==21&&hour<=24)
    {
    Tick=9;
    }
    else if(hour==22&&hour<=24)
    {
    Tick=10;
    }
    else if(hour==23&&hour<=24)
    {
    Tick=11;
    }
    else if(hour==24&&hour<=24)
    {
    Tick=12;
    }
    else
    {
    System.out.println("Time is currently at 12hour format");
    }
    {
    return Tick;
    }
    }

    public int calculate(int minute){
    {
    calculate=minute;
    }
    {
    if(minute==1)
    {
    minutes=5;
    }
    else if(minute==2)
    {
    minutes=10;
    }
    else if(minute==3)
    {
    minutes=15;
    }
    else if(minute==4)
    {
    minutes=20;
    }
    else if(minute==5)
    {
    minutes=25;
    }
    else if(minute==6)
    {
    minutes=30;
    }
    else if(minute==7)
    {
    minutes=35;
    }
    else if(minute==8)
    {
    minutes=40;
    }
    else if(minute==9)
    {
    minutes=45;
    }
    else if(minute==10)
    {
    minutes=50;
    }
    else if(minute==11)
    {
    minutes=55;
    }
    else if(minute==12)
    {
    minutes=00;
    }
    else
    {
    System.out.println("Inputted value is INVALID");
    }
    }
    {
    return minutes;
    }

    }


    public void ClockInfo()
    {
    System.out.println("Type of Clock: " + getType());
    System.out.println("Color: " + getColor());


    }


    }

    ------------------------------------------------------------------------

    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    public class Digital extends Clock {

    public Digital(String w, String m)
    {
    super(w,m);
    }

    public void Distinct()
    {
    System.out.print("\n\tMethod: display plain numbers/flashing numbers to tell time");
    System.out.print("\n\tConversion: "+getconv());
    }

    public void Location()
    {
    System.out.print("\n\tLocation: LED's, LCD's");
    }

    @Override
    public void ClockInfo()
    {
    System.out.print("\n\tMade of Clock: "+getType()+"\n\tClock color: "+getColor());
    }

    }

  2. #2
    rexter is offline Member
    Join Date
    Mar 2017
    Posts
    2
    Rep Power
    0

    Unhappy HI guys., i wonder about the problem that the netbeans compiler says main is missing

    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    import java.util.Scanner;




    public class TestClock {


    static Scanner ch = new Scanner(System.in);
    static Scanner vk = new Scanner(System.in);
    static Scanner ta = new Scanner(System.in);
    static Scanner sh = new Scanner(System.in);

    /**
    * @param args the command line arguments
    */

    public static void main(String[] args) {
    Digital aa = new Digital(" "," ");
    Analog wa = new Analog("","");
    Clock cm = new Clock(00,00);
    Clock cl = new Clock(00,00);

    int time;

    do{
    System.out.print("\n\tPress the desired number of choice, then press Enter to continue");
    System.out.print("\n\t[1] to display the Analog Clock\n\t[2] to display the Digital Clock\n\t[3] to exit");
    System.out.print("\n\t ");
    time = ta.nextInt();
    /*In analog clock, there is no possible option for indicating AM&PM*/
    if(time == 1)
    {
    System.out.print("\n\tEnter the information of Analog Clock");
    System.out.print("\n\tEnter the Brand: ");
    String t = sh.next();
    wa.setBrand(t);
    System.out.print("\n\tEnter the color: ");
    String h = sh.next();
    wa.setColor(h);
    System.out.print("\n\tEnter the Number where minute hand pointed:\n\tchoices: 1,2,3,4,5,6,7,8,9,10,11,12 ");
    System.out.print("\n\tEnter the Minute hand value : ");
    cl.setcalc(ch.nextInt());/*This is where analog clock minute hand pointed value to equivalent value,grabs inputted value*/
    wa.Distinct();/*This is where analog clock minute hand pointed value to equivalent value,displays defference between digital clock and the calculated value*/
    wa.Location();
    wa.ClockInfo();
    }
    else if(time == 2)/* SECTION FOR DIGITAL CLOCK*/
    {
    System.out.print("\n\tEnter information of the Digital Clock");
    System.out.print("\n\tEnter the Brand: ");
    String t = sh.next();
    aa.setBrand(t);
    System.out.print("\n\tEnter the color: ");
    String h = sh.next();
    aa.setColor(h);
    System.out.print("\n\tEnter the Time to identify or convert 24 to 12 time format: ");
    System.out.print("\n\tEnter the Time : ");
    cm.setconv(vk.nextInt());/*This is where digital 24hour format value to equivalent 12hour value,grabs inputted value*/
    aa.Distinct();/*This is where digital 24hour format value converted to equivalent 12hour value,displays defference between analog clock and the converted value*/
    aa.Location();
    aa.ClockInfo();
    }

    }while(time !=3);
    }
    }

    ---------------------------------------------------------------------

    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    public class Analog extends Clock {

    public Analog(String a, String n)
    {
    super(a, n);
    }


    public void Distinct()
    {
    System.out.print("\n\tCalculation: pointing numbers to tell time");
    System.out.print("\n\tCalculation: "+getcalc());
    }

    public void Location()
    {
    System.out.print("\n\tLocation: Walls");
    }
    @Override
    public void ClockInfo()
    {
    System.out.print("\n\tMade of Clock: "+getType()+"\n\tClock color: "+getColor());
    }
    }

    ---------------------------------------------------------------------------


    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    public class Clock {
    private int hour,minute,minutes;
    public int bell,Tick;

    private String type, color;
    public Clock(String t, String h)
    {
    type = t;
    color = h;

    }

    private int calculate,convert;
    public Clock(int calc, int conv)
    {
    calculate=calc;
    convert=conv;

    }

    public void setcalc(int minute){

    calculate =minutes ;
    }
    public int getcalc(){
    return minutes;
    }

    public void setconv(int hour){
    convert = Tick;
    }
    public int getconv(){
    return Tick;
    }







    public void setBrand(String t)
    {
    type = t;
    }

    public String getType()
    {
    return type;
    }

    public void setColor(String h)
    {
    color = h;
    }

    public String getColor()
    {
    return color;
    }

    public int convert(int hour){


    if(hour==13&&hour<=24)
    {
    Tick=1;
    }
    else if(hour==14&&hour<=24)
    {
    Tick=2;
    }
    else if(hour==15&&hour<=24)
    {
    Tick=3;
    }
    else if(hour==16&&hour<=24)
    {
    Tick=4;
    }
    else if(hour==17&&hour<=24)
    {
    Tick=5;
    }
    else if(hour==18&&hour<=24)
    {
    Tick=6;
    }
    else if(hour==19&&hour<=24)
    {
    Tick=7;
    }
    else if(hour==20&&hour<=24)
    {
    Tick=8;
    }
    else if(hour==21&&hour<=24)
    {
    Tick=9;
    }
    else if(hour==22&&hour<=24)
    {
    Tick=10;
    }
    else if(hour==23&&hour<=24)
    {
    Tick=11;
    }
    else if(hour==24&&hour<=24)
    {
    Tick=12;
    }
    else
    {
    System.out.println("Time is currently at 12hour format");
    }
    {
    return Tick;
    }
    }

    public int calculate(int minute){
    {
    calculate=minute;
    }
    {
    if(minute==1)
    {
    minutes=5;
    }
    else if(minute==2)
    {
    minutes=10;
    }
    else if(minute==3)
    {
    minutes=15;
    }
    else if(minute==4)
    {
    minutes=20;
    }
    else if(minute==5)
    {
    minutes=25;
    }
    else if(minute==6)
    {
    minutes=30;
    }
    else if(minute==7)
    {
    minutes=35;
    }
    else if(minute==8)
    {
    minutes=40;
    }
    else if(minute==9)
    {
    minutes=45;
    }
    else if(minute==10)
    {
    minutes=50;
    }
    else if(minute==11)
    {
    minutes=55;
    }
    else if(minute==12)
    {
    minutes=00;
    }
    else
    {
    System.out.println("Inputted value is INVALID");
    }
    }
    {
    return minutes;
    }

    }


    public void ClockInfo()
    {
    System.out.println("Type of Clock: " + getType());
    System.out.println("Color: " + getColor());


    }


    }

    ------------------------------------------------------------------------

    package parentclock;

    /**
    *
    * @author HF304-USER19
    */
    public class Digital extends Clock {

    public Digital(String w, String m)
    {
    super(w,m);
    }

    public void Distinct()
    {
    System.out.print("\n\tMethod: display plain numbers/flashing numbers to tell time");
    System.out.print("\n\tConversion: "+getconv());
    }

    public void Location()
    {
    System.out.print("\n\tLocation: LED's, LCD's");
    }

    @Override
    public void ClockInfo()
    {
    System.out.print("\n\tMade of Clock: "+getType()+"\n\tClock color: "+getColor());
    }

    }

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,942
    Rep Power
    30

    Default Re: HI guys., i wonder about the problem with my code since it wont run but no errors

    Duplicate threads merged.

    What shows on the console when you try to execute the program? What is the command line you use to execute the program?

    Did the code compile without errors?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 14
    Last Post: 04-03-2015, 11:26 PM
  2. Code wont work have no clue why
    By CreatingDrake in forum New To Java
    Replies: 12
    Last Post: 11-25-2013, 08:52 AM
  3. My NetBeans wont run/compile my code!
    By Bill Nye in forum NetBeans
    Replies: 2
    Last Post: 05-04-2012, 07:09 PM
  4. Replies: 7
    Last Post: 11-22-2010, 02:38 PM
  5. simple problem - code wont compile
    By dirtycash in forum New To Java
    Replies: 1
    Last Post: 11-20-2007, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •