Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

High level language, interfaces and structured programming logic

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a list of questions i'll appreciate explicit answers given


(1) How were higher level versions of programming languages designed from their low level representations?
How were low level representations of computer languages like machine and assembly languages abstracted to
a higher level language like java?

(2) What could be the most compelling reason(s) to create an interface for use in my program design? For most things i do
in my program design now i see that design of classes (abstract & concrete) can help me achieve the results directly.

(3) There're some lines of code i want explained. I just want to be clarified on the logic being depicted. These are few lines of
code from a section of a program fashioned to check for leap year. The program is out to explore Date.


//utility method confirm proper day value
//based on month and year

private int checkDay (int testDay)
{

" " "

if(month == 2 && testDay == 29 && (year % 400 = 0 II (year % 4 == 0 && year % 100 != 0)))

return testDay;

Where i'm not clear is the year variable in association with the modulus operator and the number 400, 4 and 100 involved.
what are the significance of these numbers in checking for leap year? i have no problem with the logical operator && joining
the first two expressions in the 'if' keyword. I'll appreciate a clear explanation.

olakunle oladipo oni
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Olakunle Oladipo Oni wrote: Where i'm not clear is the year variable in association with the modulus operator and the number 400, 4 and 100 involved.
what are the significance of these numbers in checking for leap year?


Do you know what the logic for working out a leap year is?
- It's a leap year if the year is divisible by 4
- unless it's divisible by 100, in which case it isn't
- unless it's divisible by 400, in which case it is
(It's all to do with a year not being exactly 365 days long...or even 365.25)
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
About your first question: Maybe the page History of programming languages on Wikipedia will give you some answers on this.

Olakunle Oladipo Oni wrote:if(month == 2 && testDay == 29 && (year % 400 = 0 II (year % 4 == 0 && year % 100 != 0)))


I see two errors in this line of code. The expression year % 400 = 0 is wrong; it should have been year % 400 == 0. A single = is used for assignment, and == for comparisons. Also, II (two capital letters i) will not work. Probably you meant || (two pipe symbols), which is the logical or operator.

If you have multiple, separate questions, please ask them in separate topics - it can become confusing if there are multiple discussions going on in one topic.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic