Beginner Coding – FizzBuzz Program (Java)

When learning to program, it is important that one practice what they’ve learned and what they’re currently learning, as many programming concepts lay a foundation for other concepts that you’ll learn later. A FizzBuzz program is one type of programming exercise that one can do in order to re-enforce concepts that were learned early on in their programming education.

A FizzBuzz program should:

  • Print the numbers 1 – 100
  • If a number is divisible by 3, the program should print the word “Fizz”
  • If a number is divisible by 5, the program should print the word “Buzz”
  • If a number is divisible by both 3 and 5, it should print the word “FizzBuzz”

Here’s an example of one possible solution to the FizzBuzz program, written in Java, as well as explanations as to what the code does and why it is used.


class FizzBuzz{
 
 public static void main (String[] args){
 
    //Use a "for loop" to print the numbers 1 - 100 to the screen/console,
    //as we know how many numbers will be printed at runtime.
    for(int i = 1; i <= 100; i++){

            //Check to see if a number is divisible by 3 and 5, which is done
            //first because checking for divisibility for either 3 or 5 first
            //would cause either "Fizz" or "Buzz" to be printed instead
            if(i % 3 == 0 && i % 5 == 0){
                System.out.println("FizzBuzz");
            }
            //Check for divisibility by 3 and print "Fizz" if true
            else if(i % 3 == 0){
               System.out.println("Fizz");
            }
            //Check for divisibility by 5 and print "Buzz" if true
            else if(i % 5 == 0){
                System.out.println("Buzz");
            }
            //If a number is not divisible by 3 or 5, print it normally
            else{
                System.out.println(i);
            }

     }
 
   }
}

The resulting output from this code would be:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz

Another way to check for divisibility by both 3 and 5, which would print “FizzBuzz”, one could instead check to see if a number is divisible by 15, the least common multiple of 3 and 5, which would result in the same output. Here’s what this would look like in Java code:


if(i % 15 == 0){
    System.out.println("FizzBuzz");
}

There you have it! That’s how to go about creating a “FizzBuzz” program in Java! Feel free to copy and paste the code written above into your IDE or editor of choice and play around with it, in order to what changing various lines of code could do! You could even include other checks, perhaps printing something else if a number is divisible by other numbers!

Please feel free to let me know what you think of this post in the comments or by sending me an e-mail using the Contact page, or on Twitter – @Jamiemcg! If you liked this post, I invite you to check out the TechnicalCafe YouTube channel, where you can find more tutorials on Java, HTML, CSS, and more!

Sunrise Calendar Acquired by Microsoft

Screenshot of message from within the Sunrise Calendar iOS app, explaining that Sunrise is joining Microsoft

Screenshot of Sunrise Calendar

If you’re a Sunrise Calendar user, then you may be surprised, as well as excited to learn that Sunrise Calendar has been acquired by Microsoft – something that I found out about via a recent Sunrise app update. After updating, there was a message displayed on the app, which, when tapped, brought up the message seen in the screenshot above, which reads:

It’s just the beginning.

To our friends and Sunrise users:

Today, we’re excited to announce that Sunrise is joining Microsoft. For Sunrise, this is just the beginning.

Microsoft also posted a blog post on their website, written by Rajesh Jha, Microsoft’s Corporate Vice President of Outlook and Office 365, which reads, in part:

I’m pleased to announce that Microsoft has acquired Sunrise, provider of a next-generation calendar app for iOS and Android. We are making this acquisition because we believe a reinvention in the way people use calendars on mobile devices is long overdue. Our goal is to better help people manage and make the most of their time in a mobile-first, cloud-first world.

This is another step forward on our journey to reinvent productivity and empower every person and organization to achieve more. Today’s acquisition of Sunrise, our recent acquisition of Acompli, and our new touch-optimized universal Office apps for Windows 10 all exemplify Microsoft’s ambition to rethink the productivity category. Our goal is to create more meaningful, beautiful experiences in mobile email and calendaring across all platforms. And as you will hear in the video below, the creative talent and fresh thinking at Sunrise and Acompli will make a lasting impact on the Microsoft family as we seek to reinvent productivity.

With Sunrise now backed by Microsoft’s technical and monetary resources, as well as existing software, such as Microsoft Outlook, Office, Office 365, and others, it will be interesting to see how Sunrise will be integrated into the various Microsoft products, as well as how it will be developed further as a standalone app and website.

What are your thoughts on Microsoft’s acquisition of Sunrise Calendar? Are you a user of either the Sunrise Calendar iOS and/or Android apps or the Sunrise.am website application? Please feel free to post your thoughts, comments, and feedback in the “Comments” section below!

Using Your iPhone to Track Steps

Have you ever wondered how many steps you’ve taken or how active you’ve been throughout the day, but don’t have a pedometer or fitness tracker, like the Fitbit, to track and record this data? If you happen to be running iOS 8 on an iPhone 4s or later or on an iPod Touch 5th generation or later, you can easily track your steps, distance, and other interesting and useful health data, right from your iOS device using the built-in Health app.

Introduced in iOS 8, the Health app enables users to keep track of their health and fitness data, which can be either manually entered or pulled in from other apps, like MyFitnessPal, via Apple’s HealthKit tool. Users can then view this data from with the Health app, with the option to choose which information gets displayed on their Dashboard within the app.

For those users who carry their iPhone in their pocket throughout the day, they can use the Health app to track and view data on how many steps they’ve taken, something that one would have to use either a third-party app or fitness tracker for in previous versions of iOS. Users can also view data on how much distance they’ve walked or ran, as well as what the equivalent number of floors climbed would have been.

In order to view how many steps you’ve taken, you can do so by launching the Health app, where you should see buttons on the bottom of the screen, including “Dashboard”, “Health Data”, “Sources”, and “Medical ID”.

Tapping on the “Health Data” button will bring you to a list that contains various categories of health data that you can view and edit, from vital signs, to nutrition, to fitness.

The Health Data section of Apple's Health app

The Health Data section of Apple’s Health app

From the “Health Data” menu, you can tap on “Fitness”, which will give you the option to view various kinds of fitness data, including “Active Calories”, “Cycling Distance”, “Flights Climbed”, “NikeFuel”, “Resting Calories”, “Steps”, and “Walking + Running Distance”.

The iOS Health App's "Fitness" Categories

The iOS Health App’s “Fitness” Categories

When you choose the “Steps” option, you should see a screen detailing the number of steps that you’ve taken over a time period of days, weeks, months, or the year, with the data in both numerical and graph form, allowing you to view the number of steps you’ve taken over the selected period of time.

Step data seen within the Health app on iOS 8

Step data seen within the Health app on iOS 8

In order to view the distance you’ve walked or ran, you can select the “Walking + Running Distance” option from the “Fitness” menu, where you can view both numerical and graphical data in the same time-frames as the “Steps” option.

Health App's "Distance" Screen

Distance data seen within the Health app on iOS 8

In order to make it easier to view both step and distance data, you can use the “Show on Dashboard” slider to add the desired data to the Health app’s Dashboard – that way you don’t have to traverse through the menus and options each time you’d like to view your data.

Health App Dashboard, displaying data on the number of steps taken and the distance traveled

Health App Dashboard

Tapping on the data from the Dashboard will take you to the same data and options page that you arrive at when you do so by traversing through the “Health Data” categories.

For more information regarding Apple’s Health app and HealthKit for iOS, you can check out this page from Apple’s support website, which provides information on the Health app in general, as well as what other functions you have access to with the app.

Have you tried using Apple’s Health app on iOS 8 for keeping track of your daily steps, distance, or anything else? What have your experiences been like? Please feel free to let us know in the comments section below! Also, please feel free to check out the TechnicalCafe YouTube channel for more tech news, tips, tricks, and tutorials!

2014 in Review

The WordPress.com stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

A New York City subway train holds 1,200 people. This blog was viewed about 6,300 times in 2014. If it were a NYC subway train, it would take about 5 trips to carry that many people.

Click here to see the complete report.

Favorite Apps 2014

Since 2014 is coming to a close in a less than an hour, it’s time once again for the TechnicalCafe.com “Favorite Apps” list – a list of apps that I have been using or have used throughout the past year that I have found helpful, well-designed, useful, intuitive, or simply a great way to pass time and enjoy using frequently.

Below is a list of 10 apps that were chosen (by browsing through my iPhone) that is not in any particular order, so an app’s position in the list does not reflect how “good” it is, etc. Also, there are some runners up this year, which are apps that I used and enjoyed, as well, that did not make it into the “favorite apps” top 10 list.

1. MyFitnessPal (Free, Android)

MyFitnessPal Meal ListingMyFitnessPal Chart

MyFitnessPal is a service that is offered through both an app and website, that enables users to keep track of various health and fitness related data, including food intake, exercise, weight, and more, with the goal of helping to keep users health and in shape.

Users can search for various food items from a database containing a variety of different foods by either typing the name of the food item or by scanning the barcode with the app. Should an item not come up or should a user want to enter a custom food item, they are also able to do so from within the app.

Another great feature of the MyFitnessPal app is that users who have wearable fitness items, such as the Fitbit, are able to connect their exercise information to the app, in order to see how many calories were burned, taking the data right from their wearable pedometer, etc. – something that can be useful if one is interested in finding out their net calorie intake, calories burned, in addition to other health data.

2. TweetBot 3 ($2.99)

Photo Dec 28, 12 34 41 AM

TweetBot 3 is an app that was on the list last year, and for good reason – it is a great way to view, post, and manage tweets, and also has support for multiple Twitter accounts. Supporting a variety of touch gestures, such as swiping to view a conversation, etc., as well as the ability to customize the menu, one can easily view tweets, manage conversations, interact with followers, and more! These features, and others not mentioned here, are what make TweetBot 3 worth the $2.99 price tag!

3. Alien Blue (Free, Pro Upgrade In-App Purchase Available)

Photo Dec 28, 12 33 33 AM Photo Dec 28, 12 33 39 AM

As someone who has become a frequent Reddit.com user, I discovered the Alien Blue app for Reddit this year, and have been using it frequently ever since! Purchased by Reddit a few months ago, Alien Blue is a feature-packed app that lets users view and vote on new Reddit submissions, read and reply to comments, manage which subreddits one is subscribed to, and more! There is also a paid “pro” version of the Alien Blue app, which provides more features and helps to support the development of the app!

There is also an iPad version of Alien Blue, which provides a great way for users to access Reddit on their iPads, though there is no Android version of the app available at the time of this posting. However, if you are on iOS, I would recommend giving Alien Blue a try, especially if you’re already a Redditor!

4. iStudiez Pro ($2.99)

Photo Dec 28, 12 40 30 AM Photo Dec 28, 12 40 37 AM

For those readers who are in high school or college, the iStudiez Pro app may prove useful for keeping track of classes, homework, exams, and other school-related information and data.

5. Sunrise Calendar (Free, Android)

Photo Dec 28, 12 35 31 AM Photo Dec 28, 12 35 38 AM

Sunrise Calendar is a great calendar app that I use to keep track of my schedule, be it for school, work, or events that I wish to keep track of. With two interfaces – one that enables you to view a “schedule” of your upcoming events by day of the week, along with weather information, and another that shows you three days at at time and what events are scheduled during that day and how long they are scheduled.

Sunrise Calendar supports Google Calendar and Microsoft Exchange, and also has a web-based application, at Sunrise.am, which you can use to manage your calendar from any web browser.

6. Calendars 5 ($2.99)

Photo Dec 28, 12 35 53 AM

Calendars 5, by Readdle, is another calendar app that I use to keep track of my scheduled events and appointments, as well as what work I may have due, etc. Calendars 5 offers several views of your calendar, including a daily, weekly, and monthly view option. Also included and integrated within the app is the ability to view, create, and manage Google Tasks, helping to ensure that you get everything done in a timely manner.

7. Snapchat (Free, Android)

Snapchat is a free photo and video messaging app, with the catch that each photo and video that is sent only lasts for a certain amount of time, up to ten seconds, after which point it is no longer viewable by either user of the app. Users can send photos and videos to multiple users at a time, and can even post videos to all of their friends, in the form of a “Snapchat Story”, which remains visible to users for a 24 hour period.

8. Evernote (Free, Android | Premium Upgrade Available)

Photo Dec 28, 12 38 14 AM

Evernote is a free note taking and managing app, which I have used since I briefly switched from an iPhone to a Samsung Galaxy Note 3 earlier in the year. I like the ability to use the Evernote app on my phone and MacBook Pro, as well as the option to use the web interface, should I wish to view or edit my notes on a computer or device that does not have Evernote installed.

Evernote lets users upload photos, voice clips, and more, allowing for one to keep track of all sorts of things, such as receipts, business cards, and more. There is also a paid upgrade, to Evernote Premium, which includes the ability to upload more content to one’s account, in addition to other features.

9. Shazam (Free, $6.99 Upgrade, Android, $5.59)

Shazam is a useful app for when you are curious as to what song is playing or who may sing it. All you have to do is open the Shazam app, allow it to “listen” to the song for a few seconds, after which point it will send it to Shazam’s servers and analyze it, returning information about the song that you just tagged, including the song title, artist, links to purchase it from iTunes, etc., and more.

There is also a paid version of the Shazam app, called Shazam Encore, which can be purchased for $6.99 on an iOS device and $5.59 on an Android device, and enables more features and the ability to tag more songs.

10. Mint (Free, Android)

Photo Dec 28, 12 39 31 AM Photo Dec 28, 12 40 12 AM

Mint, owned by Intuit, is a free app and service that allows users to keep track of their money and finances, including spending, income, budgets, and more. With Mint, users can add multiple accounts, including checking, savings, credit cards, etc. and see where their money has been going, thanks to a variety of helpful metrics and graphs. Users can also create and view budgets, in order to see if they are overspending on certain areas and what not.

Runners Up:

The runners up this year include DataMan Next (free), Google Maps (free, iOS | Android), Waze (free, iOS | Android), Yik Yak (free, iOS | Android), and Duo Lingo (free, iOS | Android).

If you’re interested in what apps made the list in previous years, I invite you to check out the following links to see what apps were chosen in: 2013, 2011, and in 2010.

What were some of your favorite iPhone and Android apps this year? Would you have chosen different apps for the list? Please feel free to let us know what you think or what you may have done differently in this list by posting in the comments section below!

I hope everyone has a happy, healthy, fun, and safe New Year! Thank you for visiting the TechnicalCafe.com blog and TechnicalCafe YouTube channel, and for reading and viewing our content, as well as for taking the time to leave your feedback on the blog and videos; it’s greatly appreciated! Without the readers and viewers, TechnicalCafe would not be the website and channel that it is today!

Sunrise Calendar App Review

Keeping track of your schedule, important dates, and appointments can be tricky at times. However, if you are a Google Calendar, iCloud, or Microsoft Exchange user, Sunrise Calendar, available for iOS and Android devices, is an app that allows users to keep track of their calendars and schedules on the go!

When you first launch the Sunrise Calendar application on your phone, you will be prompted to sign in Google Account, iCloud, or Exchange details, in order to sync your calendar with Sunrise.

After the syncing process, you will be able to log into any of the Sunrise Calendar apps and view, create, and edit new events and tasks, which will be synced between your calendar and the Sunrise Calendar applications, including the web-based application and the Mac OS X application.

Whenever the Sunrise Calendar app is launched, users will see their calendar in one of two views – a “list” view, which displays various days and the events that are scheduled for them or a more traditional weekly calendar view, with events taking up time-slots within a specific day, similar to what one would see in Google Calendar’s “Weekly” view.

Users can switch between the two different views by tapping on the icon that looks like three lines, located to the right of the Sunrise Calendar logo, at the top of the application.

Sunrise Calendar List View

Sunrise Calendar’s List View

Within the “List” view of a user’s calendar, the day of the week, events, and weather will be displayed. Users will also be able to view and select a particular day within two weeks of the currently selected day. Scrolling up and down will change the currently selected day, and is an easy way to view what events may have previously occurred and which events are upcoming.

Sunrise Calendar's Weekly View

Sunrise Calendar’s Weekly View

Sunrise Calendar’s weekly view is similar to that offered by other calendar apps, such as Google Calendar and the Calendar application on iOS and Mac OS X, in that it displays the day of the week and shows the events, time they begin and end, and duration of them as blocks on a grid. All day events, such as birthdays and anniversaries, will show up at the top of the particular day’s grid and timed events will show up throughout the day.

New events can be added to a calendar by tapping on the “+” at top right of the app, which will launch the “New Event” pane, where various aspects of the event can be configured, such as the event’s name or title, date, time and duration, and location.

Screenshot of adding a new event in Sunrise Calendar

Adding A New Event

The “New Event” pane also enables users to set a location for the event, invite others, set which calendar the event will be on (if there is more than one), set an alert time (which will make an audible sound at the chosen time), and add a description of the event to their calendar.

When setting a time and duration for the event, users can either manually enter or select the start and end times or alternatively tap and drag the event within the day’s grid to select when the event beings and ends, in a way similar to that of Google Calendar.

Setting an event's start time in Sunrise Calendar

Setting an event’s start time in Sunrise Calendar

Should you wish to delete an event, all you have to do is tap on the event in either the list or weekly calendar view, which will bring up the event’s information, tap on “Edit”, and then scroll to the bottom of the event and choose “Delete”.

Being a Google Calendar user, I have used the Sunrise Calendar app for a while and really like being able to access my calendar quickly and easily. The app is easy to use and does not have a large learning curve, like some of the more advanced calendar apps that are available.

I like being able to see both a list of upcoming events and a calendar-like view so that I can get a visual sense of how long an event is and what time it begins or ends. Though Sunrise Calendar does not feature screen rotation, it displays a few days worth of events in both view modes, with the ability to scroll to see more. It would be nice to see a monthly calendar view with the ability to select an individual day in the past or future, but the app still works well and gets the job done.

Overall, if you’re looking for a new calendar app that is simple to use and offers a variety of great features, you should definitely consider trying Sunrise Calendar for iOS or Android, which is available from Apple’s App Store or the Google Play Store for free.

Sunrise also has a free web-based version, as well as an app for Mac OS X, both of which are pretty similar and provide a convenient way to view and edit your calendars while you’re on the computer.

Have you used Sunrise Calendar? Please feel free to leave a comment below with any questions, thoughts, or opinions you may have! Also, if you’re interested in tech related videos, please feel free to head on over to the TechnicalCafe YouTube channel!

DataMan App Review

Many iPhone users probably know the problem of worrying about how much cellular data they may have used during their billing period, especially if they do not have an unlimited data plan. Even then, some users may simply be curious as to how much data they use over time.

DataMan, by XVision, is an iPhone application that enables users to keep track of their data usage, both over a cellular connection, such as 3G, 4G, and LTE, as well as over WiFi. Perhaps one of the better features of the DataMan app is that is tracks users’ data usage in real-time and displays it in a simple, easy-to-read manner, which is nice, as sometimes cell phone carriers can take a while to update customers’ data usage and show it on their accounts.

Additionally, DataMan provides users with a reading of how much, as well as what percentage of their data cap they have already used, with the level of detail (Minimal, Standard, or Complete) configurable by the user.

For example, the “Complete” complexity setting shows users how much data they have used over both their cellular network and WiFi, providing details regarding how much data was uploaded and downloaded on both. Users will also see their “forecast” and the percentage of their data cap that they have already used during their current billing period, as well as how much time is left until the next billing period begins.

DataMan Main Screen with complexity level set to "Complete"

DataMan Main Screen with complexity level set to “Complete”

Also, the app can alert users when they have reached certain percentages of their data allowance. These alerts can be configured by the user to remind them at various percentage points of their data allowance.

When configuring DataMan, users can enter in the date that their cell phone plan resets, the length of their billing period, what their data cap is, as well as how much data they may have already used (which you may need to get from your carrier if you are unsure), and DataMan will do the rest, even resetting itself once the billing period is up.

DataMan Plan Settings

DataMan Cell Phone Plan Settings Menu

The app also provides a variety of color and theme options, allowing the user to set their desired font, as well as what colors the app’s theme will use.

DataMan's Color Settings

DataMan’s Color Settings

DataMan is available in two versions – DataMan Next (which is the app that is shown in this review) and DataMan Pro, with there being some minor differences between the two different versions. (The Pro version supports mapping where data was used, push notifications, better data usage forecasts, which apps use the most data, etc.) However, the DataMan Next version of the app should be enough to get the average user through their billing cycles without having any overages.

DataMan Next can be purchased from the App Store for $1.99 and DataMan Pro can be purchased from the App Store for $4.99.

If you have tried using DataMan Next or DataMan Pro to help keep track of your cell phone’s data usage, please feel free to post your experiences in the comments section of this post! Also, any questions about the apps are welcome, and I’ll try to answer whatever I can!

Please feel free to use the Contact page of the TechnicalCafe website to send any suggestions on which apps, etc. that you would like to see reviewed or explained in a future blog post!