Wednesday, September 9, 2015

JungOl Question 1001 (http://jungol.co.kr/problem.php?id=1001)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.*;
public class Main {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        
        for(;;){
         
         //input, two numbers
         int total, totalLeg;
            total = sc.nextInt();
            totalLeg = sc.nextInt();
            
            //input 0 -> stop program
            if(total == 0 || totalLeg == 0){
             break;
            }
            
            //input validation
            if(total > 1000 || total < 0 || totalLeg > 4000 || totalLeg < 0){
             System.out.println("INPUT ERROR!");
            }else{
             
             Boolean findFlag = false; 
                
             //Generate two numbers(dog and chick), sum of which are totalLeg(second input)
                for(int dog = 0;dog <= total;dog++){
                 
                 int chick = total  - dog;
                 int computedLeg = dog * 4 + chick * 2; 
                 
                 //if the number is found -> print "dog" and "leg" and break;
                 if(totalLeg == computedLeg){
                  System.out.println(dog + " " + chick);
                  findFlag = true;
                  break;
                 }
                }
                
                //No matching -> print "0"
                if(!findFlag){
                 System.out.println("0");
                }
                
            }
            
        }

 }

}

Basic Java Example, Standard I/O, Get get numbers using standard input and display sum of two numbers

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a, b;
        a = sc.nextInt();
        b = sc.nextInt();
        System.out.println(a + b);
    }
}

Friday, June 17, 2011

ASP .NET MVC3 Application Structure with Code(Read Data))



The first time I learned Model-View-Controller(MVC) concept, it was very difficult to understand concept of it. However, by doing a real project I could clearly understand MVC concept. Here is an example that read data from database and show result using MVC concept in ASP .NET framework. I hope it is helpful for programmers who want to learn MVC concept.



Saturday, June 11, 2011

Web Application MVC Project Structure in ASP .NET


App_Data : Physical data is stored
Content : CSS, images and any other static files are saved
Controllers:
Models: Classes that represent the application model for MVC Web Application are stored
Scripts :
Views :

ASP .NET MVC3 ViewBag

A ViewBag is a dynamic object that can be used to pass data from Controllers to Views as you use ViewData[]. It enables developers can use get/set values and add additional fields without strongly-typed classes. To understand this concepts, let's compare ViewData[] and ViewBag.

- Using ViewData[]
-Controller
public ActionResult Index()
{
List<string> colors = new List<string>();
colors.Add("red");
colors.Add("green");
colors.Add("blue");

ViewData["listColors"] = colors;
ViewData["dateNow"] = DateTime.Now;
ViewData["name"] = "Hajan";
ViewData["age"] = 25;

return View();
}
-Views
<p>
My name is
<b><%: ViewData["name"] %>b>,
<b><%: ViewData["age"] %>b> years old.
<br />
I like the following colors:
p>
<ul id="colors">
<% foreach (var color in ViewData["listColors"] as List<string>){ %>
<li>
<
font color="<%: color %>"><%: color %>font>
li>
<% } %>
ul>
<p>
<%: ViewData["dateNow"] %>
p>

- Using ViewBag
-Controller
public ActionResult Index()
{
List<string> colors = new List<string>();
colors.Add("red");
colors.Add("green");
colors.Add("blue");

ViewBag.ListColors = colors; //colors is List
ViewBag.DateNow = DateTime.Now;
ViewBag.Name = "Hajan";
ViewBag.Age = 25;
return View();
}
-Views
<p>
My name is
<b><%: ViewBag.Name %>b>,
<b><%: ViewBag.Age %>b> years old.
<br />
I like the following colors:
p>
<ul id="colors">

<% foreach (var color in ViewBag.ListColors) { %>
<li>
<font color="<%: color %>"><%: color %>font>
li>
<% } %>

ul>
<p>
<%: ViewBag.DateNow %>
p>

Change the body style in ASP .NET framework




the main CSS file is int the content folder and is named Site.css. To change the body style, right-click inside the body style description in the code, and click Build Sytle on the shortcut menu


Thursday, May 26, 2011

Software Requirements Specification Template and Example

Software Requirements express the needs and constraints placed on a software product that contribute to the solution of some real-world problem[ALA 04]. Software requirements that are clearly defined help software engineers to better understand the problems they will work to solve. However, defining software requirements is one of the most difficult tasks in software development. In this article, I will show software requirements specification template and example to understand what is clearly defined software requirements.

1. Introduction
1.1. purpose

- Business Goal

The business goal of the Global Personal Marketplace (GPM) system is to take advantage of the Internet and World Wide Web to radically improve the way private individuals and small companies buy and sell items.

- Buyer Business Benefits

Reference
[ALA 04]Alain Abran, Pierre Bourque, Leonard L.Tripp, Software Engineering body of Knowledge, IEEE, 2004

to be continue...