SENTINEL

SENTINEL

PLZ GIVE THE SUGGESTION,WHERE I MUST PUT THE SENTINEL IN THIS PROGRAME OR CODING

public class DayType{ final static int SUN = 0; final static int MON = 1; final static int TUE = 2; final static int WED = 3; final static int THU = 4; final static int FRI= 5; final static int SAT = 6;

    private int day;

    public DayType(int day) {
            this.day = day;
    }

    public void setDay(int day){
            this.day = day;
    }

    public int getDay() {
            return day;
    }

    public void print() {
            System.out.println(this.toString());
    }
    public int nextDay(){
            int next;
            next = day + 1;
            return next;
    }
    public int previousDay(){
            int prevDay;
            prevDay = day - 1;
            return prevDay;
    }
    public int addDays(int days) {
            return (day + days) % 7;
    }
            public String toString() {
            switch (this.day) {
            case SUN:
                    return "Sunday";
            case MON:
                    return "Monday";
            case TUE:
                    return "Tuesday";
            case WED:
                    return "Wednesday";
            case THU:
                    return "Thursday";
            case FRI:
                    return "Friday";
            case SAT:
                    return "Saturday";
            }
            return "";
    }       
    public static void main(String[] args) {
            System.out.println("******Test Day******");
            System.out.println();
            System.out.print("Set day: ");
            DayType d = new DayType(SUNDAY);
            d.print();
            System.out.print("Next day: ");
            d.setDay(d.nextDay());
            d.print();
            System.out.print("Previous day: ");
            d.setDay(d.previousDay());
            d.print();
            System.out.print("After 5 days: ");
            d.setDay(d.addDays(5));
            d.print();
    }

}

View Answers

February 8, 2011 at 1:00 PM

Implementation of DayType class

import java.util.*;
public class DayType{
    final static int SUN = 0;
    final static int MON = 1;
    final static int TUE = 2;
    final static int WED = 3;
    final static int THU = 4;
    final static int FRI= 5;
    final static int SAT = 6;
    private int day;
    public void setDay(int day){
            this.day = day;
    }
    public int getDay() {
            return day;
    }
    public void print() {
            System.out.println(this.toString());
    }
    public int nextDay(){
            int next;
            next = day + 1;
            return next;
    }
    public int previousDay(){
            int prevDay;
            prevDay = day - 1;
            return prevDay;
    }
    public int addDays(int days) {
            return (day + days) % 7;
    }
            public String toString() {
            switch (this.day) {
            case SUN:
                    return "Sunday";
            case MON:
                    return "Monday";
            case TUE:
                    return "Tuesday";
            case WED:
                    return "Wednesday";
            case THU:
                    return "Thursday";
            case FRI:
                    return "Friday";
            case SAT:
                    return "Saturday";
            }
            return "";
    }       
    public static void main(String[] args){
            DayType d = new DayType();
            Scanner input=new Scanner(System.in);
            boolean check=false;
            do{
            System.out.println("******Test Day******");
            System.out.println("1 Set day");
            System.out.println("2 Print day");
            System.out.println("3 Return day");
            System.out.println("4 Return Previous day");
            System.out.println("5 Return Next day");
            System.out.println("6 Exit");
            System.out.println();

            System.out.print("Enter your choice: ");
            int num=input.nextInt();
            switch(num){
            case 1:
            System.out.print("Set day(0-6): ");
            int day=input.nextInt();
            d.setDay(day);
            break;
            case 2:
            d.print();
            break;
            case 3:
            System.out.print("Next day: ");
            d.setDay(d.nextDay());
            d.print();
            break;
            case 4:
            System.out.print("Previous day: ");
            d.setDay(d.previousDay());
            d.print();
            case 5:
            System.out.print("Add no of days: ");
            int no=input.nextInt();
            d.setDay(d.addDays(no));
            d.print();
            break;
            case 6:
            check=true;
            break;
            }
            }
            while(!check);
    }
}

February 8, 2011 at 7:24 PM

thank you very much friend...









Related Tutorials/Questions & Answers:
SENTINEL
SENTINEL  PLZ GIVE THE SUGGESTION,WHERE I MUST PUT THE SENTINEL IN THIS PROGRAME OR CODING public class DayType{ final static int SUN = 0; final static int MON = 1; final static int TUE = 2; final
sentinel value
sentinel value  how to count the number of red cars that assume 10 cars using sentinel value
Advertisements
sentinel value
sentinel value  how to count the number of red cars. Assume there are 10 cars.   how to count the number of red cars that assume 10 cars using sentinel value
sentinel value
sentinel value  how to count the number of red cars. Assume there are 10 cars
ModuleNotFoundError: No module named 'sentinel'
ModuleNotFoundError: No module named 'sentinel'  Hi, My Python... 'sentinel' How to remove the ModuleNotFoundError: No module named 'sentinel... to install padas library. You can install sentinel python with following
ModuleNotFoundError: No module named 'mqtt-sentinel'
ModuleNotFoundError: No module named 'mqtt-sentinel'  Hi, My... 'mqtt-sentinel' How to remove the ModuleNotFoundError: No module named 'mqtt-sentinel' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo-sentinel'
ModuleNotFoundError: No module named 'odoo-sentinel'  Hi, My... 'odoo-sentinel' How to remove the ModuleNotFoundError: No module named 'odoo-sentinel' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python_sentinel'
ModuleNotFoundError: No module named 'python_sentinel'  Hi, My... named 'python_sentinel' How to remove the ModuleNotFoundError: No module named 'python_sentinel' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python_sentinel'
ModuleNotFoundError: No module named 'python_sentinel'  Hi, My... named 'python_sentinel' How to remove the ModuleNotFoundError: No module named 'python_sentinel' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sentinel-util'
ModuleNotFoundError: No module named 'sentinel-util'  Hi, My... 'sentinel-util' How to remove the ModuleNotFoundError: No module named 'sentinel-util' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'smart-sentinel'
ModuleNotFoundError: No module named 'smart-sentinel'  Hi, My... named 'smart-sentinel' How to remove the ModuleNotFoundError: No module named 'smart-sentinel' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-sentinel'
ModuleNotFoundError: No module named 'django-sentinel'  Hi, My... named 'django-sentinel' How to remove the ModuleNotFoundError: No module named 'django-sentinel' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Flask-Sentinel'
ModuleNotFoundError: No module named 'Flask-Sentinel'  Hi, My... named 'Flask-Sentinel' How to remove the ModuleNotFoundError: No module named 'Flask-Sentinel' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'beaker_extensions_sentinel'
ModuleNotFoundError: No module named 'beaker_extensions_sentinel'  Hi...: No module named 'beaker_extensions_sentinel' How to remove the ModuleNotFoundError: No module named 'beaker_extensions_sentinel' error? Thanks
ModuleNotFoundError: No module named 'Flask-Redis-Sentinel'
ModuleNotFoundError: No module named 'Flask-Redis-Sentinel'  Hi...: No module named 'Flask-Redis-Sentinel' How to remove the ModuleNotFoundError: No module named 'Flask-Redis-Sentinel' error? Thanks   Hi
ModuleNotFoundError: No module named 'kyc-sentinel-rest-client'
ModuleNotFoundError: No module named 'kyc-sentinel-rest-client'  Hi...: No module named 'kyc-sentinel-rest-client' How to remove the ModuleNotFoundError: No module named 'kyc-sentinel-rest-client' error? Thanks  
ModuleNotFoundError: No module named 'kyc-sentinel-rest-client'
ModuleNotFoundError: No module named 'kyc-sentinel-rest-client'  Hi...: No module named 'kyc-sentinel-rest-client' How to remove the ModuleNotFoundError: No module named 'kyc-sentinel-rest-client' error? Thanks  
ModuleNotFoundError: No module named 'Redis-Sentinel-Url'
ModuleNotFoundError: No module named 'Redis-Sentinel-Url'  Hi, My... named 'Redis-Sentinel-Url' How to remove the ModuleNotFoundError: No module named 'Redis-Sentinel-Url' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'sb-django-redis-sentinel'
ModuleNotFoundError: No module named 'sb-django-redis-sentinel'  Hi...: No module named 'sb-django-redis-sentinel' How to remove the ModuleNotFoundError: No module named 'sb-django-redis-sentinel' error? Thanks  
ModuleNotFoundError: No module named 'scrapy-redis-sentinel'
ModuleNotFoundError: No module named 'scrapy-redis-sentinel'  Hi...: No module named 'scrapy-redis-sentinel' How to remove the ModuleNotFoundError: No module named 'scrapy-redis-sentinel' error? Thanks   Hi
ModuleNotFoundError: No module named 'tornado-redis-sentinel'
ModuleNotFoundError: No module named 'tornado-redis-sentinel'  Hi...: No module named 'tornado-redis-sentinel' How to remove the ModuleNotFoundError: No module named 'tornado-redis-sentinel' error? Thanks   Hi
ModuleNotFoundError: No module named 'Azure-Sentinel-Utilities'
ModuleNotFoundError: No module named 'Azure-Sentinel-Utilities'  Hi...: No module named 'Azure-Sentinel-Utilities' How to remove the ModuleNotFoundError: No module named 'Azure-Sentinel-Utilities' error? Thanks  
ModuleNotFoundError: No module named 'beaker_extensions_sentinel'
ModuleNotFoundError: No module named 'beaker_extensions_sentinel'  Hi...: No module named 'beaker_extensions_sentinel' How to remove the ModuleNotFoundError: No module named 'beaker_extensions_sentinel' error? Thanks
ModuleNotFoundError: No module named 'celery-redis-sentinel'
ModuleNotFoundError: No module named 'celery-redis-sentinel'  Hi...: No module named 'celery-redis-sentinel' How to remove the ModuleNotFoundError: No module named 'celery-redis-sentinel' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-redis-sentinel'
ModuleNotFoundError: No module named 'django-redis-sentinel'  Hi...: No module named 'django-redis-sentinel' How to remove the ModuleNotFoundError: No module named 'django-redis-sentinel' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-redis-sentinel-plugin'
ModuleNotFoundError: No module named 'django-redis-sentinel-plugin'  ...: No module named 'django-redis-sentinel-plugin' How to remove the ModuleNotFoundError: No module named 'django-redis-sentinel-plugin' error
ModuleNotFoundError: No module named 'django-redis-sentinel-redux'
ModuleNotFoundError: No module named 'django-redis-sentinel-redux'  ...: No module named 'django-redis-sentinel-redux' How to remove the ModuleNotFoundError: No module named 'django-redis-sentinel-redux' error? Thanks
ModuleNotFoundError: No module named 'Flask-Redis-Sentinel'
ModuleNotFoundError: No module named 'Flask-Redis-Sentinel'  Hi...: No module named 'Flask-Redis-Sentinel' How to remove the ModuleNotFoundError: No module named 'Flask-Redis-Sentinel' error? Thanks   Hi
Maven Repository/Dependency: com.infinum.sentinel | sentinel
Maven Repository/Dependency of Group ID com.infinum.sentinel and Artifact ID sentinel. Latest version of com.infinum.sentinel:sentinel dependencies. # Version Release Date 1
com.infinum.sentinel - sentinel version 1.3.1 Maven dependency. How to use sentinel version 1.3.1 in pom.xml?
com.infinum.sentinel  - Version 1.3.1 of sentinel Maven dependency? How to use  com.infinum.sentinel  - Version 1.3.1 of sentinel in pom.xml? How to use sentinel version 1.3.1 in pom.xml? Learn to use this dependency
Maven dependency for com.infinum.sentinel - sentinel version 1.2.2 is released. Learn to use sentinel version 1.2.2 in Maven based Java projects
of sentinel released The developers of   com.infinum.sentinel - sentinel..., the released version of  com.infinum.sentinel - sentinel library is 1.2.2. Developer can use this version ( com.infinum.sentinel - sentinel version 1.2.2
how to find [count the number of integers whose value is less than the average value of the integers]
a collection of payroll amounts entered at the terminal until a sentinel amount of 999 is entered. After the sentinel has been entered, display the total payroll
java compilation - Design concepts & design patterns
a `$` sentinel.  Hi Friend, Try the following code: import java.util.
Creat a program MinMax.java
Creat a program MinMax.java  Create a program MinMax.java that finds and prints the minimum and the maximum of integers read in from the keyboard. Use -9999 as a sentinel to stop the read. Do not count -9999 as one
java program
java program  A user will input a sequence of positive integers ending with a sentinel -1. write a while loop hat counts the number of even an dodd integers and prints the cumulative total. for example, if the input is 1 7 2 9
a java program
a java program  Write a java program that accepts positive numbers from the user and finds both the average, maximum, and the minimum value of entered numbers. The sentinel value (the last value that differs from the previous
convert jp2 to geotiff
({});   Hi, sentinel jp2 is the earth image with geo information
INTEGERS
results. Use class Scanner and sentinel-controlled repetition to obtain the data
In Java..
the sentinel value -1. After all data has been read, the tester class should
Logic and desgin HELP just need to get started on this.
is finished. When purchases are complete, enter a sentinel value of -1 (Make certain you do not include the -1 sentinel value in your total). Keep track

Ads