logotransparent.png

Legion of Learners

www.lol-101.com

  • Home

  • Classrooms

  • Courses

  • About Us

    • Executive Team
    • Board Members
  • Resources

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    kevinzhao183
    Jan 24, 2021

    Intro to Java 1/23/21 Homework

    in Java Question Bank

    Write a program that uses a loop to add up all the multiples of three from 1 to 100. Challenge: write three programs, each using a different type of loop. (Hint: If you want to check if a number is a multiple of three, you might need to use an if statement. Also, if a number n % 3 is equal to zero, what does that mean?)

    2 comments
    0
    brendan.yen
    Jan 30, 2021

    class Main { public static void main(String[] args) { int a = 0; for (int x = 0; x<100; x++){ if (x % 3 == 0) { a = a + x; } } System.out.println(a); } }

    0
    777mysha
    Jan 30, 2021

    class Main {

    public static void main(String[] args) {

    int x = 0;

    for (int y=0; y<100; y++) {

    if (y%3 == 0) {

    x = x + y;

    }

    }

    System.out.println(x);

    }

    }

    0
    2 comments

    Questions? Email us at legionoflearners@gmail.com or join our WeChat group!

    • lol-101dotcom

    ©2020 Legion of Learners