ErSKS / Java

Java Training
http://khec.edu.np/
MIT License
16 stars 17 forks source link

Decode CRN #31

Closed ErSKS closed 7 years ago

ErSKS commented 7 years ago

Develop a java program to display Batch, Department & Roll Number of user input. User input should be 6-character string such as 710339, 650101, etc.

Example:

User Input: 71AB39 - Not a valid CRN User Input: 7103396 - Not a valid CRN User Input: Nepal - Not a valid CRN User Input: 710339 - Valid CRN

Decoded Output

Batch: 2071 Department: Computer Engineering Roll No.: 39

milan604 commented 7 years ago

Program package decodecrn;

import java.util.Scanner; import java.util.regex.Pattern;

/*

screenshot from 2017-08-10 15-29-54

ErSKS commented 7 years ago

@milan604 Display useful error message of the input ABCDEF : It's not a CRN.

jagdish4249 commented 7 years ago

package stringinput;

import static java.lang.Integer.parseInt; import javax.swing.JOptionPane;

/*

} capture

capture

capture

rivab commented 7 years ago

package day8tasklast;

import javax.swing.JOptionPane;

/*

karmi214 commented 7 years ago

/*

import static java.lang.Integer.parseInt; import javax.swing.JOptionPane;

/*

} 1 2 3 4

Sudan15423 commented 7 years ago

/*

import java.util.Scanner; import javax.swing.JOptionPane;

/*

} input output invalidinput invalid

sajanbasnet75 commented 7 years ago

/*

import javax.swing.JOptionPane;

/*

}

111 112 in1 in2

ghost commented 7 years ago

package day08lastone;

import javax.swing.JOptionPane;

/*

syslin commented 7 years ago

/*

import java.util.Scanner;

/*

kajalmaharjan commented 7 years ago

/*

import javax.swing.JOptionPane;

/*

maheshyakami commented 7 years ago

/*

import javax.swing.JOptionPane;

/*

}

screen shot 2017-08-10 at 9 09 31 pm screen shot 2017-08-10 at 9 11 42 pm screen shot 2017-08-10 at 9 13 45 pm screen shot 2017-08-10 at 9 13 51 pm
rabina12 commented 7 years ago

package day8a2;

import javax.swing.JOptionPane;

/*

} capture1 capture1a capture1c

RakenShahi commented 7 years ago

/*

import java.util.Scanner; import javax.swing.JOptionPane;

/*

OUTPUT decode1 decode2

ajay987 commented 7 years ago

public static void main(String[] args) { // TODO code application logic here String str; int cg, ch, rn;

    str = JOptionPane.show

op1 op2 op3 op2 op5 op6

String str; int cg, ch, rn;

    str = JOptionPane.showInputDialog("Enter your id number");
    if (str.length() == 6) {
        cg = Integer.parseInt(str.substring(0, 2));
        System.out.println("Batch:20" + cg);
        ch = Integer.parseInt(str.substring(2, 4));
        if (ch == 01) {
            System.out.println("Department:Civil Engineering");
        } else if (ch == 02) {
            System.out.println("Department:Architecture");
        } else if (ch == 03) {
            System.out.println("Department:Computer Engineering");
        } else if (ch == 04) {
            System.out.println("Department:Electronics Engineering");
        }
        rn = Integer.parseInt(str.substring(4, 6));
        System.out.println("Roll No:" + rn);
        String sp = "true";
    } else {
        JOptionPane.showMessageDialog(null, "not valid");

    }

}
ErSKS commented 7 years ago

I saw your coding diversity. Try to understand and write as clean & atomic as you can. Still I found error on your code, check your solution again.

@milan604 7103ab ab is not a roll number @jagdish4249 Ok @rivab 7103ab - java.lang.NumberFormatException @karmi214 Ok Susan Ok @sajanbasnet75 Ok @kajalmaharjan After 1st mistake attempt, your code doesn't function well

Note:- Try to find out bug of your friend's code too.