Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,844 questions

51,765 answers

573 users

How to write the 7 BOOM game. If a number divide by 7 OR include the digit 7, print "BOOM". The input is 1-99 in C#

2 Answers

0 votes
using System;
 
public class Game7BOOM_CSharp {
    public static void Main(string[] args) {
 
        Console.Write("Enter a number between 1 to 99: ");
        int n = int.Parse(Console.ReadLine());
 
        if (n % 7 == 0 || n / 10 == 7 || n % 10 == 7) {
            Console.WriteLine("BOOM");
        } else {
            Console.WriteLine(n);
        }
    }
}
 
   
   
/*
run:
   
Enter a number between 1 to 99: 17
BOOM
   
*/


answered Apr 10, 2014 by avibootz
edited Aug 29, 2024 by avibootz
0 votes
using System;
 
public class Game7BOOM_CSharp {
    public static void Main(string[] args) {
 
        Console.Write("Enter a number between 1 to 99: ");
        int limit = int.Parse(Console.ReadLine());
 
        for (int i = 1 ; i <= limit ; i++) {
            if (i % 7 == 0 || i / 10 == 7 || i % 10 == 7) {
                Console.WriteLine("BOOM");
            } else {
                Console.WriteLine(i);
            }
        }
    }
}
 
   
   
/*
run:
   
1
2
3
4
5
6
BOOM
8
9
10
11
12
13
BOOM
15
16
BOOM
18
19
20
BOOM
22
23
24
25
26
BOOM
BOOM
29
30
   
*/

 



answered Aug 29, 2024 by avibootz
edited Aug 29, 2024 by avibootz
...