SlideShare a Scribd company logo
1 of 3
Download to read offline
1.「It is cold today」と画面に表示するように、次のプログラムの空欄を埋めて下さい。
/* 問題 1 */
public class Problem1
{
public static void main(String[] args)
{
}
}
2.Java 言語の変数名として、正しい場合は○、間違いである場合には×を、括弧内に記入して下さい。
(1) sample-1 ( ) (2) p42*1 ( ) (3) 12th_street( )
(4) smartphone ( ) (5) RED ( ) (6) winter ( )
3.次のJava 言語の式を計算し、括弧内に計算結果を記入して下さい。
(1) 19 % 5 ( ) (2) 20 / 5 ( )
(3) 4 * 5 / 3 - 2 ( ) (4) 4 * ( 5 - 2 * 2 ) ( )
4.次のプログラムを実行したとき、画面に表示される値を記述して下さい。
/* 問題 4 */
public class Problem4
{
public static void main(String[] args)
{
int e = 3;
e = e + e ;
System.out.println( e) ;
}
}
5.次の式を Java 言語で記述して下さい。尚、a、b、c、d、e、f、g はdouble 型の変数名とします。
(1) c = a - b2
(2) g = d ( e - a f )
科目:文法 java 2017 秋期 中間試験問題(全 10 問) 2017 年 12 月 21 日
6.次のプログラムは、Scanner クラスを用いてキーボードから長方形の横の長さ(width)と縦の長さ(height)を
整数として入力させ長方形の面積(area)を計算し表示します。空欄を埋めてプログラムを完成させて下さい。
/* 問題 6 */
import java.util.Scanner;
public class Problem6
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int ;
System.out.print("Input a width=");
width = sc.nextInt();
System.out.print("Input a height=");
height = sc.nextInt();
area = width * height ;
System.out.println( area );
}
}
7.次のプログラムを実行したとき、画面に表示される文字を記述して下さい。
/* 問題 7 */
public class Problem7
{
public static void main(String[] args)
{
int k;
k = 60 ;
if ( k > 80 ) { System.out.println ("A") ; }
else if ( k >70 ) { System.out.println ("B") ; }
else if ( k >60 ) { System.out.println ("C") ; }
else { System.out.println ("E") ; }
}
}
8.「java java java java 」と画面に表示するように、次のプログラムの空欄を埋めて下さい。
/* 問題 8 */
public class Problem8
{
public static void main(String[] args)
{
for( )
{
System.out.print( "java ") ;
}
}
}
9.Scanner クラスを用いてキーボードから入力された座標値(x , y)が、下図A に示す原点O(0 , 0)を中心とする
横の長さ12、縦の長さ6 の長方形の内部(斜線部分、輪郭線を含む)に位置する場合は IN、外部に位置する
場合はOUT と表示するプログラムを作成してください。クラス名は problem9 とします。
例えば、
4 ←キーボードからx の値を入力する。
2 ←キーボードからy の値を入力する。
IN ←(4 , 2)は長方形の内部に位置するので、IN と表示される。
図A 長方形の内部を表す座標系、座標値
10.Scanner クラスを用いてキーボードから変数n に整数の値を入力させ、その値n を用いて次のように表示
するプログラムを作成して下さい。クラス名は problem10 とします。
例えば、
3 ←キーボードから変数 n に3 を入力する。
* *
*
* * ←このように表示される。
例えば、
4 ←キーボードから変数 n に4 を入力する。
* *
* *
* *
* * ←このように表示される。
例えば、
5 ←キーボードから変数 n に5 を入力する。
* * *
* *
* * *
* *
* * * ←このように表示される。
例えば、
6 ←キーボードから変数 n に6 を入力する。
* * *
* * *
* * *
* * *
* * *
* * * ←このように表示される。
以上
x
y
O
12
2
5
(4 , 2)
×
6-6
-3
3

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

2017秋期 文法java-中間試験ー問題

  • 1. 1.「It is cold today」と画面に表示するように、次のプログラムの空欄を埋めて下さい。 /* 問題 1 */ public class Problem1 { public static void main(String[] args) { } } 2.Java 言語の変数名として、正しい場合は○、間違いである場合には×を、括弧内に記入して下さい。 (1) sample-1 ( ) (2) p42*1 ( ) (3) 12th_street( ) (4) smartphone ( ) (5) RED ( ) (6) winter ( ) 3.次のJava 言語の式を計算し、括弧内に計算結果を記入して下さい。 (1) 19 % 5 ( ) (2) 20 / 5 ( ) (3) 4 * 5 / 3 - 2 ( ) (4) 4 * ( 5 - 2 * 2 ) ( ) 4.次のプログラムを実行したとき、画面に表示される値を記述して下さい。 /* 問題 4 */ public class Problem4 { public static void main(String[] args) { int e = 3; e = e + e ; System.out.println( e) ; } } 5.次の式を Java 言語で記述して下さい。尚、a、b、c、d、e、f、g はdouble 型の変数名とします。 (1) c = a - b2 (2) g = d ( e - a f ) 科目:文法 java 2017 秋期 中間試験問題(全 10 問) 2017 年 12 月 21 日
  • 2. 6.次のプログラムは、Scanner クラスを用いてキーボードから長方形の横の長さ(width)と縦の長さ(height)を 整数として入力させ長方形の面積(area)を計算し表示します。空欄を埋めてプログラムを完成させて下さい。 /* 問題 6 */ import java.util.Scanner; public class Problem6 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int ; System.out.print("Input a width="); width = sc.nextInt(); System.out.print("Input a height="); height = sc.nextInt(); area = width * height ; System.out.println( area ); } } 7.次のプログラムを実行したとき、画面に表示される文字を記述して下さい。 /* 問題 7 */ public class Problem7 { public static void main(String[] args) { int k; k = 60 ; if ( k > 80 ) { System.out.println ("A") ; } else if ( k >70 ) { System.out.println ("B") ; } else if ( k >60 ) { System.out.println ("C") ; } else { System.out.println ("E") ; } } } 8.「java java java java 」と画面に表示するように、次のプログラムの空欄を埋めて下さい。 /* 問題 8 */ public class Problem8 { public static void main(String[] args) { for( ) { System.out.print( "java ") ; } } }
  • 3. 9.Scanner クラスを用いてキーボードから入力された座標値(x , y)が、下図A に示す原点O(0 , 0)を中心とする 横の長さ12、縦の長さ6 の長方形の内部(斜線部分、輪郭線を含む)に位置する場合は IN、外部に位置する 場合はOUT と表示するプログラムを作成してください。クラス名は problem9 とします。 例えば、 4 ←キーボードからx の値を入力する。 2 ←キーボードからy の値を入力する。 IN ←(4 , 2)は長方形の内部に位置するので、IN と表示される。 図A 長方形の内部を表す座標系、座標値 10.Scanner クラスを用いてキーボードから変数n に整数の値を入力させ、その値n を用いて次のように表示 するプログラムを作成して下さい。クラス名は problem10 とします。 例えば、 3 ←キーボードから変数 n に3 を入力する。 * * * * * ←このように表示される。 例えば、 4 ←キーボードから変数 n に4 を入力する。 * * * * * * * * ←このように表示される。 例えば、 5 ←キーボードから変数 n に5 を入力する。 * * * * * * * * * * * * * ←このように表示される。 例えば、 6 ←キーボードから変数 n に6 を入力する。 * * * * * * * * * * * * * * * * * * ←このように表示される。 以上 x y O 12 2 5 (4 , 2) × 6-6 -3 3